繁体   English   中英

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

[英]npm ERR! code E401 npm ERR! Incorrect or missing password

我的节点版本是 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
  1. 尝试在升级节点版本后运行命令“npm install”之前删除 package-lock.json 文件,如果您还没有这样做的话。

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

NPM ERR Code E401:无法认证,需要:承载授权

我在.npmrc中配置的公司注册表也有同样的错误

registry=https:<company-registry-url>

节点版本: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>.

在此.npmrc更新后

//<registry-url>/:_authToken=xxxxx

你在 .npmrc 中的密码必须是 base64 编码的。 只需复制粘贴密码即可轻松搞砸,需要对其进行 base64 编码。

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

删除以下文件:

.cache
.package
.package-lock
.npmrc

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

npm i

与 Node 16.xx 有同样的问题我已经完成了这个主题和这里提到的那些主题的所有事情,但没有任何帮助!

唯一帮助我登录的是我从这里删除了 Node 16.xx安装了 Node 14.8.1 - https://nodejs.org/en/download/releases/

在运行npm run dev之后,我最近在各种项目中遇到了同样的错误:

npm ERR! code E401
npm ERR! Incorrect or missing password.

为我解决的问题是删除我的package-lock.json yarn.lock (以及任何可能与 npm 产生冲突的 yarn.lock 文件)和node_modules目录。 然后我用npm update更新了我的 npm 包。 (注意:在更新任何 npm 软件包之前,您可能应该创建一个新的 Git 分支并在该新分支中运行npm update 。如果您在更新后遇到更大的问题,则可以恢复到以前的分支。)

更新我的包后,运行我的 npm 启动脚本(例如npm run dev )再次运行而没有错误。

注意:您可以运行已过期的npm outdated以查看您的哪些 npm 包可以使用更新。

它可能是由于 npm 上的错误而发生的。 npm v7 发生在我身上。 切换到 v6 并且它有效。

更多上下文: https ://github.com/npm/cli/pull/2153

重新安装最新的 node.js。 这解决了我的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM