npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@neotales/is-elevated

v0.0.0

Published

isElevated function determines if the current process is running elevated (admin/root) across windows, linux, and darwin platforms.

Readme

@neotales/is-elevated

Overview

@neotales/is-elevated detects whether the current process is running with elevated privileges. On Unix-like systems this typically means root. On Windows it checks whether the current token is elevated.

logo

JSR npm version GitHub version

Documentation

Documentation is available on jsr.io.

A list of other modules can be found at github.com/neotales/js-os.

Installation

deno add jsr:@neotales/is-elevated
npx jsr add @neotales/is-elevated
npm install @neotales/is-elevated

Usage

import { isElevated } from "@neotales/is-elevated";

if (!isElevated()) {
  throw new Error("Run this as admin/root");
}

Exports

| Export | Subpath | Description | | ------------ | ----------------------- | ------------------------------------------------ | | isElevated | @neotales/is-elevated | Detects whether the current process is elevated. |

import { isElevated } from "@neotales/is-elevated";

const elevated = isElevated();

if (elevated) {
  console.log("ready for privileged work");
}

Elevation Detection

On Unix-like systems, elevation means an effective user ID of 0. Node and Bun check process.geteuid() when available, then fall back to process.getuid(). The result is cached so repeated checks do not need to query the runtime again.

On Windows, the package opens the current process token and calls GetTokenInformation with TokenElevation. Node uses native node:ffi when available and otherwise the optional koffi dependency; Bun and Deno use their native FFI implementations. The FFI implementations are loaded only on Windows.

This intentionally does not use Shell32.IsUserAnAdmin. That API checks administrator-group membership rather than the current process token, so it can disagree under User Account Control when an administrator account is running with a filtered, non-elevated token. TokenElevation reports the process state directly.

Runtime Support

This npm package supports Node, Bun, and Deno. Deno users can import it with npm:@neotales/is-elevated. Call isElevatedAvailable() before relying on Windows elevation detection when the runtime's FFI configuration may be unknown.

  • Deno: run with --allow-ffi.
  • Bun: the native bun:ffi backend is selected automatically.
  • Node.js: see Node.js FFI.

Node.js FFI

On Windows, Node.js requires a native FFI backend. Run Node >= 26 with --experimental-ffi to enable node:ffi, or install koffi with npm install koffi when optional dependencies were omitted or unavailable. When neither is available, isElevatedAvailable() returns false and isElevated() throws an error that links to this section.

License

MIT License