is-globally-installed
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

is-globally-installed

Check if this package was installed globally by NPM or Volta (other package managers are untested).

By using is-globally-installed as a dependency, your own package can determine if it was also installed globally or locally.

Install

npm install is-globally-installed

Usage

import isGloballyInstalled from 'is-globally-installed';

// If `npm install your-package`
console.log(isGloballyInstalled); // => false

// If `npm install --global your-package`
console.log(isGloballyInstalled); // => true

Why use this package over others?

Most other packages (like is-global or is-installed-globally) rely on checking the path of the installed package. This method doesn't work with tools like Volta where global packages are not installed directly under NPM's global prefix. Instead this package uses a simpler and more direct approach. It just checks for the environment variable npm_config_global, which is automatically defined by NPM (and Volta) when installed globally (during post-install). This approach has the added benefit of the package not having any dependencies.

Package Sidebar

Install

npm i is-globally-installed

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

3.8 kB

Total Files

6

Last publish

Collaborators

  • aidinabedi