npm install给出了未经授权的名称或密码错误

Tha*_*ers 31 install tap node.js npm

当我尝试使用安装水龙头时

npm install tap
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

npm ERR! Error: unauthorized Name or password is incorrect.: tap
Run Code Online (Sandbox Code Playgroud)

这是整个回复:

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!     <npm-@googlegroups.com>

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
Run Code Online (Sandbox Code Playgroud)

Tha*_*ers 93

找到了答案.

从我的主目录中删除.npmrc,它的工作原理!

感谢mcollina https://github.com/mcollina,网址https://github.com/isaacs/npm/issues/2778

  • 我的`.npmrc`文件中有auth凭据,但未在公共注册中心注册.如果你在该文件中有其他配置对,你可以删除你应该很好的auth行(_auth,email). (2认同)

sid*_*kar 19

 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.
Run Code Online (Sandbox Code Playgroud)


sam*_*rav 10

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


Chr*_*dam 6

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

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


小智 6

在我的例子中,删除 package-lock.json 和 node_modules 就成功了。