@esm2cjs/npm-run-path

Add local node_modules binaries to PATH for script execution.

npmmacoslinuxwindows
Try with needOr install directly
Source

About

Get your PATH prepended with locally installed binaries. This is a fork of sindresorhus/npm-run-path, but with CommonJS support.

Examples

run locally installed command from node_modules$ npx @esm2cjs/npm-run-path --help
get PATH with node_modules binaries prepended in Node.js$ node -e "const npmRunPath = require('@esm2cjs/npm-run-path'); console.log(npmRunPath())"
execute script with access to local npm packages$ node -e "const {execSync} = require('child_process'); const npmRunPath = require('@esm2cjs/npm-run-path'); execSync('eslint .', {env: {...process.env, PATH: npmRunPath()}})"
add node_modules to PATH in shell environment$ export PATH="$(node -e \"console.log(require('@esm2cjs/npm-run-path')())\")":$PATH
find local command without installing globally$ which $(node -e "const p = require('@esm2cjs/npm-run-path'); console.log('webpack')") || echo 'not found'