-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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] Windows npm install --prefix errors and looks for the package.json in the cwd #7722
Comments
There are a couple of workarounds to this bug for those who are blocked by this.
and
Neither of those versions of the incantation appear to be affected by this bug. |
(I was not able reproduce this problem on macOS with npm 10.2.4 or npm 10.8.2.) |
|
Can repro from CMD, Git Bash, Powershell
|
I found that globalDir/localDir and globalPrefix/localPrefix end up being the same value when `--prefix` is set. This was surprising to me, but it does appear that `globalPrefix` is set to match `prefix` at the end of loading. This means that the globalTop logic is actually incorrect here. It accidentally worked on non-windows machines. For example if running `npm i --prefix scripts` On non-windows this.npm.globalDir = $CWD/scripts/lib/node_modules On windows this.npm.globalDir = $CWD/scripts/node_modules IMHO, the logic inside of npmconfig is also incorrect here, since globalDir is being set to this bogus `$CWD/scripts/lib/node_modules` However, this fix should work regardless - since it stops relying on the specific values of globalDir. Fixes npm#7722 I manually tested `npm install` and `npm install --prefix` on both windows and mac. Everything works now.
I spent a couple hours looking into this since I have the repro. Got a fix here #7725 |
Closing This is similer if not duplicate of #4511 |
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
Errors saying it cannot find
package.json
Expected Behavior
Install packages to the directory where the prefix is and package.json.
Steps To Reproduce
1, Use Windows 11
2. Use Node 18, 20, 22 ...
3. Use latest npm
4. Try an install with --prefix
In this repo https://github.com/get-convex/convex-backend, which has a scripts subfolder.
error
Environment
The text was updated successfully, but these errors were encountered: