The npm community forum has been discontinued.
To discuss usage of npm, visit the GitHub Support Community.
login / adduser doesn't work when you have separate accounts for different scopes in the same registry
What I Wanted to Do
Login and stay logged in with 2 accounts on https://registry.npmjs.org/, each for a different scope.
I want to see 2 _authToken entries in ~/.npmrc.
What Happened Instead
The second login replaced the general _authToken for the same registry, instead of adding one for the same registry, but a different scope.
> npm login --scope=@A Username: a Password: XXXX Email: (this IS public) personal@emailProvider.com Logged in as a to scope @A on https://registry.npmjs.org/.
There is an _authToken in ~/.npmrc
> npm login --scope=@B Username: b Password: YYYYY Email: (this IS public) firstname.lastname@example.org Logged in as a to scope @B on https://registry.npmjs.org/.
There is another _authToken in ~/.npmrc
The first token (
WWWW-WWWWW-WWWWW-WWWWW) is gone.
Rinse and repeat.
Yeah this is kinda deeply embedded in the design of our auth system. Can you tell me more about why you’re trying to do this?
I need to use different personas, often with different email addresses, for different clients, and personal work. When they use the same registry URI, e.g., the public npm registry, I’m toast (or at least, it’s a hassle, and error prone).
You could maybe create a separate
.npmrc for each persona in the relevant directories, with some (possible) problems:
- Your login is unavailable outside of those directories
- I don’t know if
.npmrcs outside your home directory
- I don’t know if the auth would be loaded properly
(I’ll try to test this)
No, this doesn’t seem to work.
This is my recommendation tbh