npm install gives unauthorized name or password is incorrect error
Asked Answered
J

12

47

When I try to install tap using

npm install tap

I get the following error:

npm ERR! Error: unauthorized Name or password is incorrect.: tap

Here's the entire response:

npm http GET https://registry.npmjs.org/tap
npm http 401 https://registry.npmjs.org/tap
npm ERR! Error: unauthorized Name or password is incorrect.: tap
npm ERR!     at RegClient.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:253:14)
npm ERR!     at Request.init.self.callback (/usr/local/lib/node_modules/npm/node_modules/request/main.js:120:22)
npm ERR!     at Request.EventEmitter.emit (events.js:91:17)
npm ERR!     at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/main.js:648:16)
npm ERR!     at Request.EventEmitter.emit (events.js:115:20)
npm ERR!     at IncomingMessage.Request.start.self.req.self.httpModule.request.buffer (/usr/local/lib/node_modules/npm/node_modules/request/main.js:610:14)
npm ERR!     at IncomingMessage.EventEmitter.emit (events.js:115:20)
npm ERR!     at IncomingMessage._emitEnd (http.js:366:10)
npm ERR!     at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)
npm ERR!     at CleartextStream.socketOnData (http.js:1366:20)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Linux 3.2.0-31-generic-pae
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "tap"
npm ERR! cwd /home/thaddeus
npm ERR! node -v v0.8.8
npm ERR! npm -v 1.1.59
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/thaddeus/npm-debug.log
npm ERR! not ok code 0
Jeffereyjefferies answered 30/9, 2012 at 0:0 Comment(1)
It happen to me that I had another registry in ~/.npmrc (I needed it some time ago and I forgot to remove it)Duda
J
117

Found the answer.

Remove .npmrc from my home directory and it works!

Thanks to mcollina https://github.com/mcollina at https://github.com/isaacs/npm/issues/2778

Jeffereyjefferies answered 30/9, 2012 at 0:0 Comment(3)
I had auth credentials in my .npmrc file which weren't registered with the public registry. If you have other config pairs in that file, you could just remove the auth lines (_auth, email) you should be good to go.Harbour
I get the same error. I have auth token in npmrc file.How do I update the token?Tachometer
For me it was coming from the fact that the content of the .npmrc changed afterwards, I simply updated the content of my local file with the new one and it worked!Ostrowski
S
25
 1.>Go to your this location

    C:\Users\{your user name or ID}

 2.> open .npmrc & Remove all content from .npmrc file.

 3.>reopen your new command prompt

 4.>again run the code , will work.
Suborder answered 18/4, 2016 at 9:30 Comment(1)
I just removed the whole file, it worked (mac). Thanks.Barclay
S
10

I was also having this problem. Mine has arised because I have changed my password in npmjs.org. So, try Login in npm from terminal again with your new password and then install any module. It worked for me.

Supplicate answered 23/9, 2013 at 6:52 Comment(0)
R
9

You might have _auth entry configured in the .npmrc config file ($HOME/.npmrc). Just delete the entry if you are using the public registry as it's not needed. If you're using a private npm registry you should check with your admin that that's the correct auth key for you to access the registry.

I would not recommend just deleting the whole file (.npmrc) as the file might contain important configurations for your npm to work correctly. i.e.: proxy config.

Retouch answered 23/10, 2014 at 14:33 Comment(0)
S
6

Removing package-lock.json and node_modules did the trick in my case.

Salcedo answered 26/10, 2017 at 11:0 Comment(0)
Y
2

Also you can use

npm cache clean
Yorktown answered 3/3, 2014 at 20:45 Comment(0)
N
1

i tried

npm cache clean

but it didn't work. I didn't see .npmrc in my directory. I killed my bash shell (terminal on mac) and brought up a new one and that seemed to do the trick. Not sure if it was the bash refresh or the npm cache clean or a combination of the two.

Nolen answered 14/8, 2014 at 17:5 Comment(0)
M
1

npm cache verify is what you need

Misbecome answered 28/11, 2018 at 15:36 Comment(0)
L
0

If you have changed your system LAN password, run npm login and provide your new password.

Once the login is successful, you will not get error while doing npm install.

Lunn answered 2/4, 2020 at 18:47 Comment(0)
R
0

I had a an odd issue where I got the credentials error and it was because npm login had cached bad credentials and then npm logout didn't clear the credentials (as evidenced by "npm login" always showing my default details).

NPM stores your login under the globals NPM_CONFIG_EMAIL and NPM_CONFIG__AUTH. If you do "npm config ls -la" and see email under "environment configs" you may have the same issue I had (where npm logout didn't work).

Unset the globals NPM_CONFIG__AUTH and NPM_CONFIG_EMAIL and then npm login again and it should work. (in terminal it's just "unset NPM_CONFIG__AUTH")

Resourceful answered 2/11, 2020 at 15:59 Comment(0)
T
0

For me I needed to create a account in npm site, after that sing in via terminal into npm using npm login, remove the .npmrc file from your /home folder and after that try npm install again in your project folder

Tinny answered 18/11, 2021 at 17:44 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Dysthymia
A
0

In our case, our NPM repository is actually managed by our company, so our value for "registry=xxx" inside my global .npmrc file was different in our case. Verify with your company if you guys handle your NPM registries differently then using the npm site itself.

Anxious answered 14/11, 2022 at 19:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.