I want to automate the npm login process via a bash script.
I tried it with this snippet:
/usr/bin/expect -f - <
I don't know if it is in any way secured so please do some research before.
But the fact is that npm
is storing all those informations into a file. If you look at:
cat ~/.npmrc
It could be interesting enough so you could do the login dance only once.
I found that on Windows Server 2012R2, there is some odd behaviour with service accounts. This method worked for me (as part of a Jenkins build, under bash):
cat > ~/.npmrc <<EOL
//my.local.registry:4873/:_authToken="G....................A=="
always_auth=true
registry=http://my.local.registry:4873/
user=aRegisteredUser
EOL
My Solution is to use plugin npm-login-cmd
npm install -g npm-login-cmd
export NPM_USER=user
export NPM_PASS=pass
export NPM_EMAIL=valid email syntax
npx npm-login-cmd
login work on enterprice npm repository