Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] ENOENT on npm exec if prefix directory doesn't exist #5942

Closed
2 tasks done
cbay opened this issue Dec 8, 2022 · 1 comment
Closed
2 tasks done

[BUG] ENOENT on npm exec if prefix directory doesn't exist #5942

cbay opened this issue Dec 8, 2022 · 1 comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release

Comments

@cbay
Copy link

cbay commented Dec 8, 2022

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

Starting with 19a8346, a simple npm exec foo fails with ENOENT if the prefix directory specified in npmrc doesn't exist:

$ npm exec foo
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path /home/cbay/.npm-packages/lib
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, lstat '/home/cbay/.npm-packages/lib'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

$ cat ~/.npmrc 
prefix = /home/cbay/.npm-packages

$ ls /home/cbay/.npm-packages
ls: cannot access '/home/cbay/.npm-packages': No such file or directory

Expected Behavior

It used to work just fine until that commit:

$ npm exec foo
Need to install the following packages:
  [email protected]
Ok to proceed? (y)

Steps To Reproduce

No response

Environment

This was tested on Node.js 18.8.0 and 19.1.0. It worked fine on 18.7.0.

@cbay cbay added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Dec 8, 2022
m4dz added a commit to m4dz/npm-cli that referenced this issue Jan 19, 2023
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
@milaninfy
Copy link
Contributor

This is fixed on latest npm ( 10.8.3 ) #7640 please update and check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants