Skip to content

Commit

Permalink
Fix npm#5942 - ENOENT on npm exec
Browse files Browse the repository at this point in the history
When running `npm exec` and the global path specified using config's `prefix` doesn't exist, execution fails when npm lfirst ooks for the package availability at global level to run it. Testing the presence of the `prefix` (a.k.a `globalPath`) directory rather than just testing the `globalPath` directive fix this issue.

This bug was introduced by commit 19a8346, so this patch can be backported to npm > 8.12.1
  • Loading branch information
m4dz authored Jan 19, 2023
1 parent b74f834 commit 3f41308
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion workspaces/libnpmexec/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const exec = async (opts) => {

args[0] = getBinFromManifest(commandManifest)

if (needInstall.length > 0 && globalPath) {
if (needInstall.length > 0 && await fileExists(globalPath)) {
// See if the package is installed globally, and run the translated bin
const globalArb = new Arborist({ ...flatOptions, path: globalPath, global: true })
const globalTree = await globalArb.loadActual()
Expand Down

0 comments on commit 3f41308

Please sign in to comment.