npm 错误!代码 E401 npm ERR!密码不正确或丢失

use*_*989 9 javascript node.js npm

我的 Node 版本是 10.15.0,NPM 版本是 6.8.4 在将 npm 升级到 14.16.0 和 npm 到 7.6.2 后运行 npm install

收到此错误 -

npm ERR! code E401
npm ERR! Incorrect or missing password.
npm ERR! If you were trying to login, change your password, create an
npm ERR! authentication token or enable two-factor authentication then
npm ERR! that means you likely typed your password in incorrectly.
npm ERR! Please try again, or recover your password at:
npm ERR!     https://www.npmjs.com/forgot
npm ERR! 
npm ERR! If you were doing some other operation then your saved credentials are
npm ERR! probably out of date. To correct this please try logging in again with:
npm ERR!     npm login

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/xyz/.npm/_logs/2021-04-15T18_55_07_993Z-debug.log
Run Code Online (Sandbox Code Playgroud)

小智 12

在目录中C/Users/your-windows-username/

删除以下文件:

.cache
.package
.package-lock
.npmrc
Run Code Online (Sandbox Code Playgroud)

之后,转到您的项目并在终端中运行以下命令

npm i
Run Code Online (Sandbox Code Playgroud)


jaf*_*mlp 10

我在配置的公司注册表中遇到了同样的错误.npmrc

registry=https:<company-registry-url>
Run Code Online (Sandbox Code Playgroud)

节点版本:19.1.0
NPM版本:8.19.3

解决方案:

执行npm login

$ npm login
npm notice Log in on https:<registry-url>
Username: xxxx
Password:
Email: (this IS public) (xxxx)
Logged in as xxx on https:<registry-url>.
Run Code Online (Sandbox Code Playgroud)

.npmrc更新后

//<registry-url>/:_authToken=xxxxx
Run Code Online (Sandbox Code Playgroud)


par*_*xiR 6

  1. 如果您还没有这样做,请尝试在升级节点版本后运行命令“npm install”之前删除 package-lock.json 文件。

  2. 如果这不起作用,请尝试删除本文中提到的 $HOME 目录中的 .npmrc 文件。

NPM ERR 代码 E401:无法验证,需要:承载授权

  • 是的,我完全错过了。删除 package-lock.json 对我有用。谢谢! (3认同)
  • 请参阅[这个答案](/sf/ask/3788682341/#54127283)了解您可能不想删除`package-的潜在原因锁.json`。 (3认同)