Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm login - Registry returned 401 for PUT

I am trying to login to npm by doing npm login and entering username, password, and email but I am receiving the following response:

Registry returned 401 for PUT

npm is saying that I have the incorrect username or password, but I've used the same credentials to login to npmjs.org.

version of node is: node -v v6.2.2

like image 326
jacoballenwood Avatar asked Jun 19 '17 18:06

jacoballenwood


3 Answers

Solutions with .npmrc and/or npm config were not working for me. Eventually found the error was for and older npm version with 2fa enabled (see this thread).

So the following should work

npm update npm -g
npm login

-- update

On a different machine this didn't work until I updated NodeJS and did npm i npm -g.

like image 67
Sjeiti Avatar answered Oct 17 '22 17:10

Sjeiti


I guess, that you have overdid registry. For checking, please, run npm config get registry. You should see

▶ npm config get registry
https://registry.npmjs.org/

If there is not this message, then use npm config set registry https://registry.npmjs.org/

like image 2
galkin Avatar answered Oct 17 '22 18:10

galkin


I had an npmrc located at ~/.npmrc and removed it with rm ~/.npmrc and it seemed to fix the issue.

The file contained an authToken in the registry so I suppose it was conflicting with the login? I'm not sure...

like image 2
jacoballenwood Avatar answered Oct 17 '22 17:10

jacoballenwood



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!