Gathering detailed insights and metrics for npm-path
Gathering detailed insights and metrics for npm-path
Gathering detailed insights and metrics for npm-path
Gathering detailed insights and metrics for npm-path
Get a PATH containing locally installed module executables.
npm install npm-path
Typescript
Module System
Min. Node Version
Node Version
NPM Version
95.8
Supply Chain
100
Quality
75.6
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
259,969,080
Last Day
103,140
Last Week
548,568
Last Month
2,277,018
Last Year
24,284,950
MIT License
50 Stars
56 Commits
5 Forks
3 Watchers
2 Branches
4 Contributors
Updated on Mar 29, 2025
Minified
Minified + Gzipped
Latest Version
2.0.4
Package Id
npm-path@2.0.4
Size
7.93 kB
NPM Version
5.6.0
Node Version
8.9.1
Published on
Jan 06, 2018
Cumulative downloads
Total Downloads
Last Day
67.2%
103,140
Compared to previous day
Last Week
2.1%
548,568
Compared to previous week
Last Month
6%
2,277,018
Compared to previous month
Last Year
-18.1%
24,284,950
Compared to previous year
1
npm-path
will get you a PATH with all of the executables available to npm scripts, without booting up all of npm(1).
npm-path
will set your PATH to include:node_modules/.bin
directories from the current directory, up through all of its parents. This allows you to invoke the executables for any installed modules. e.g. if mocha
is installed a dependency of the current module, then mocha
will be available on a npm-path
generated $PATH
.node
executable, so any scripts that invoke node
will execute the same node
.node-gyp
directory, so the node-gyp
bundled with npm
can be used.1# Prints the augmented PATH to the console 2> npm-path 3# /usr/local/lib/node_modules/npm/bin/node-gyp-bin:.../node_modules/.bin:/.../usr/local/bin:/usr/local/sbin: ... etc
Calling npm-path
from the commandline is the equivalent of executing an npm script with the body echo $PATH
, but without all of the overhead of booting or depending on npm
.
This will set the augmented PATH for the current process environment, or an environment you supply.
1var npmPath = require('npm-path') 2var PATH = npmPath.PATH // get platform independent PATH key 3 4npmPath(function(err, $PATH) { 5 6 // Note: current environment is modified! 7 console.log(process.env[PATH] == $PATH) // true 8 9 console.log($PATH) 10 // /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/.../.bin:/usr/local/bin: ...etc 11 12}) 13 14// more explicit alternative syntax 15npmPath.set(function(err, $PATH) { 16 // ... 17})
1 2// supplying no callback will execute method synchronously 3var $PATH = npmPath() 4console.log($PATH) 5 6// more explicit alternative syntax 7$PATH = npmPath.setSync()
1var options = { 2 env: process.env, // default. 3 cwd: process.cwd() // default. 4} 5 6npmPath(options, function(err, $PATH) { 7 // ... 8}) 9 10npmPath.setSync(options) 11 12 // ... 13
This will get npm augmented PATH, but does not modify the PATH in the environment.
Takes the exact same options as set
.
1npmPath.get(function(err, $PATH) { 2 console.log($PATH) 3 4 // Note: current environment is NOT modified! 5 console.log(process.env[PATH] == $PATH) // false 6}) 7 8// options is optional, takes same options as `npmPath.set` 9npmPath.get(options, function(err, $PATH) { 10 console.log($PATH) 11})
1// supplying no callback will execute method synchronously 2var $PATH = npmPath.get() 3console.log($PATH) 4console.log(process.env[PATH] == $PATH) // false 5 6// more explicit alternative syntax 7$PATH = npmPath.getSync() 8
Both set
and get
take an optional options object, with optional env
& cwd
keys.
options.env
if you wish to use something other than process.env
(the default)options.cwd
if you wish to use something other than process.cwd()
(the default)There's also a options.npm
property which you can set if you want node-gyp
to be sourced from
an alternative npm
installation.
1// windows calls it's path "Path" usually, but this is not guaranteed. 2npmPath.PATH // 'Path', probably 3 4// rest of the world 5npmPath.PATH // 'PATH' 6
1process.env[npmPath.PATH] // get path environment variable 2 3// set path environment variable manually 4process.env[npmPath.PATH] = npmPath.get() 5 6// set path environment variable automatically 7npmPath()
1// windows 2npmPath.SEPARATOR // ';' 3 4// rest of the world 5npmPath.SEPARATOR // ':'
Path lookup code adapted directly from npm.
Thanks to Jordan Harband for his hard work adapting this to work on node 0.8.
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 5/10 approved changesets -- score normalized to 5
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-04-28
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More