[BUG] npm_execpath
is set to the path of npx
instead of npm
#6662
Labels
Bug
thing that needs fixing
Needs Triage
needs review for next steps
Release 9.x
work is associated with a specific npm 9 release
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
The env
npm_execpath
can be path ofnpx
instead ofnpm
if the user runs a command withnpx
, e.g.npx node -e "console.log(process.env.npm_execpath)"
, the output will be/path/to/npm/9.8.1/bin/npx-cli.js
cli/workspaces/config/lib/set-envs.js
Line 106 in 4689ae4
I did not find the official definition for
npm_execpath
, but I assume it should only be the path ofnpm
based its name, not the path ofnpx
.Some popular libraries, e.g
npm-run-all
, usingnpm_execpath
and assuming it's the package manager path and addrun
arg to it, so if you runnpx npm-run-all test
, it is the same asnpx run test
which will install a package calledrun
and throw errors.Yarn also suggests use
$npm_execpath run <name>
which can cause the same problem: https://yarnpkg.com/advanced/rulebook#published-packages-should-avoid-using-npm-run-in-their-scriptsExpected Behavior
npm_execpath
should always be set as the path ofnpm
.Steps To Reproduce
Run
npx node -e "console.log(process.env.npm_execpath)"
The output will be
/path/to/npm/9.8.1/bin/npx-cli.js
Environment
The text was updated successfully, but these errors were encountered: