cli
cli copied to clipboard
[BUG] `npm login --location project` not writing to project configuration
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
The token is written to ~/.npmrc.
Expected Behavior
The token is written to .npmrc (same level as package.json)
Steps To Reproduce
$ npm --version
10.4.0
$ rm -f ~/.npmrc
$ cd /tmp
$ mkdir foobar
$ cd foobar
$ npm init -y > /dev/null
$ npm login --location project
npm notice Log in on https://registry.npmjs.org/
Login at:
https://www.npmjs.com/login?next=/login/cli/d3adc0de…
Press ENTER to open in the browser...
Logged in on https://registry.npmjs.org/.
$ cat .npmrc
cat: .npmrc: No such file or directory
$ cat ~/.npmrc
//registry.npmjs.org/:_authToken=npm_d3adc0de…
Environment
- npm: 10.4.0
- Node.js: v20.11.0
- OS Name: Ubuntu 22.04.1 LTS
- System Model Name: ?
- npm config:
; "user" config from /root/.npmrc //registry.npmjs.org/:_authToken = (protected) ; node bin location = /usr/local/lib/node_modules/node/bin/node ; node version = v20.11.0 ; npm local prefix = /tmp/foobar ; npm version = 10.4.0 ; cwd = /tmp/foobar ; HOME = /root ; Run `npm config ls -l` to show all defaults.
Latest npm is v10.4.0, ftr.
Latest npm is v10.4.0, ftr.
ah very well – updated, same same.
@p3k As far as I know --location flag is not a valid configuration option for npm login command. By default npm login will write the information to ~/.npmrc. Checkout npm login for more information.