I am using two NPM accounts: a public one and a private one. How would I set it up so that I don\'t need to npm login
every time I publish a module on a different a
I know I'm a bit late (okay, super late) in answering this, but I've just come across the same issue whilst having to publish to both private and public registries in quick succession.
The best solution I found to this issue is by having a second or third configuration file at the user level. This is how my
$HOME
directory looks at the moment:
Admins-iMac% ls -la ~/.npmrc*
-rw------- 1 moi staff 52 10 Apr 14:48 /Users/moi/.npmrc
-rw-r--r-- 1 moi staff 498 10 Apr 14:52 /Users/moi/.npmrc-private-reg
-rw-r--r-- 1 moi staff 70 10 Apr 14:48 /Users/moi/.npmrc-public-reg
In the "private" and "public" dotfiles I have Artifactory and npmjs.org user setups respectively, but aside from that they're empty. My default NPM configuration file also has very little inside it, as most of my configuration sits in a global file, the reasons behind that are beside the point for this question though...
When it comes to me publishing a module to either registry, I simply pass the
--userconfig
option with the path to the file that I wish to authenticate with.
For example, I just pushed a package to the public NPM registry with ease, like this:
npm publish --userconfig ~/.npmrc-public-reg