cli
cli copied to clipboard
[BUG] "npm config set cafile" changes absolute paths specified with environment variables
Is there an existing issue for this?
- [X] I have searched the existing issues
This issue exists in the latest npm version
- [X] I am using the latest npm
Current Behavior
I'm trying to configure a project using the command line by setting a custom registry and CA file. The project will be built in a docker container, so all configuration should be configured relative to the project, and nothing from the host should be referenced.
Since npm automatically turns the relative paths into absolute paths when setting cafile, let's try an use an environment variable as documented here: https://docs.npmjs.com/cli/v7/configuring-npm/npmrc
npm config set cafile='\${PWD}/cafile.crt' --location=project
This results in the bug:
cafile=/absolute/path/to/project/${PWD}/cafile.crt
This is also an issue without setting location
Expected Behavior
I expect
npm config set cafile='\${PWD}/cafile.crt'
To write:
cafile=${PWD}/cafile.crt
Steps To Reproduce
- run
npm config set cafile='\${PWD}/cafile.crt'
- see that unexpected data is written to .npmrc
Environment
- npm: 8.16.0
- Node.js: 16.14.2
- OS Name: MacOS Big Sur
- System Model Name:
- npm config:
; copy and paste output from `npm config ls` here