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] Prefix in .npmrc ignored #6081

Closed
2 tasks done
berarma opened this issue Jan 24, 2023 · 4 comments · Fixed by #6685
Closed
2 tasks done

[BUG] Prefix in .npmrc ignored #6081

berarma opened this issue Jan 24, 2023 · 4 comments · Fixed by #6685
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 9.x work is associated with a specific npm 9 release

Comments

@berarma
Copy link

berarma commented Jan 24, 2023

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

I'm trying to change the prefix for the current project using a .npmrc file.

The prefix in the .npmrc file is ignored. Tested with npm install and npm prefix.

The output of node prefix is the current directory instead of the configured directory.

Expected Behavior

I expected npm to use the prefix in the .npmrc file.

Steps To Reproduce

  1. Create file .npmrc with contents prefix=./vendor.
  2. Run npm prefix or npm install.
  3. The first command shows the current directory and install creates ./node_modules in the current directory.

Environment

  • npm: 9.3.1
  • Node.js: v14.21.2
  • OS Name: Debian GNU/Linux 11.5
  • System Model Name: PC
  • npm config:
; "project" config from /home/xxxx/yyyy/.npmrc

prefix = "/home/xxxx/yyyy/vendor" 

; node bin location = /usr/bin/node
; node version = v14.21.2
; npm local prefix = /home/xxxx/yyyy
; npm version = 9.3.1
; cwd = /home/xxxx/yyyy
; HOME = /home/xxxx
; Run `npm config ls -l` to show all defaults.
@berarma berarma added Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release labels Jan 24, 2023
@wraithgar
Copy link
Member

prefix can not be changed from the project level, npm has already parsed that level of config by the time it is parsing the .npmrc file.

npm should probably log an error if it sees you trying to do that.

@wraithgar wraithgar added Priority 2 secondary priority issue and removed Needs Triage needs review for next steps labels Jan 24, 2023
@berarma
Copy link
Author

berarma commented Jan 24, 2023

Any other way to change the location of the node_modules directory inside the project that doesn't require environment variables or command options? I would like it to be as automatic as possible based on the current directory.

@ljharb
Copy link
Contributor

ljharb commented Jan 24, 2023

No, and lots of tooling depends on it being in that exact location, so it shouldn’t be moved.

@rahulio96
Copy link
Contributor

Hello, I'm an intern at CodeDay Labs and I've been working on resolving this issue alongside my teammate, Aaron.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 9.x work is associated with a specific npm 9 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants