npm install | npm ERR! Incorrect or missing password.

前端项目更新,执行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: /usr/local/www/.npm/_logs/2024-10-28T10_39_48_122Z-debug-0.log

错误原因: 私有包需要用户权限

排查解决过程:

        1、确认.npmrc配置文件中设置的源地址不是私有库地址。

                npm config get registry

                设置为阿里源:npm config set registry https://registry.npmmirror.com

        2、查看日志(此方法解决)

                查看/usr/local/www/.npm/_logs/2024-10-28T10_39_48_122Z-debug-0.log 日志文件

                确认异常包具体报错原因,如果.npmrc文件中是公有库地址,异常报错为私有库地址,则说明有缓存。

                解决:删除node_modules和package-lock.json ,重新执行npm install

        

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值