node.js npm install 给出未经授权的名称或密码不正确错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12657560/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 16:23:05  来源:igfitidea点击:

npm install gives unauthorized name or password is incorrect error

node.jsinstallnpmtap

提问by Thaddeus Albers

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

回答by Thaddeus Albers

Found the answer.

找到了答案。

Remove .npmrc from my home directory and it works!

从我的主目录中删除 .npmrc 并且它可以工作!

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

感谢 mcollina https://github.com/mcollinahttps://github.com/isaacs/npm/issues/2778

回答by siddhartha shankar

 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.

回答by sam100rav

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.

我也遇到了这个问题。我的出现是因为我在 npmjs.org 中更改了密码。因此,尝试使用新密码从终端再次登录 npm,然后安装任何模块。它对我有用。

回答by cSn

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.

您可能在 .npmrc 配置文件 ($HOME/.npmrc) 中配置了 _auth 条目。如果您正在使用公共注册表,则只需删除该条目,因为它不需要。如果您使用的是私有 npm 注册表,您应该与您的管理员确认这是您访问注册表的正确身份验证密钥。

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.

我不建议只删除整个文件 (.npmrc),因为该文件可能包含让 npm 正常工作的重要配置。即:代理配置。

回答by Vlad Dohotaru

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

删除 package-lock.json 和 node_modules 在我的情况下起到了作用。

回答by Branislav Djuric

Also you can use

你也可以使用

npm cache clean

回答by Michael Connor

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.

但它没有用。我在我的目录中没有看到 .npmrc。我杀死了我的 bash shell(mac 上的终端)并带来了一个新的,这似乎可以解决问题。不确定是 bash 刷新还是 npm 缓存清理或两者的组合。

回答by Edwin Ikechukwu Okonkwo

npm cache verifyis what you need

npm cache verify是你需要的

回答by harsh pamnani

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

如果您更改了系统 LAN 密码,请运行npm login并提供新密码。

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

登录成功后,执行时不会出错npm install