首页IT科技npm install出错(npm install 提示Unable to authenticate, need: BASIC realm=“Sonatype Nexus Repository Manager“)

npm install出错(npm install 提示Unable to authenticate, need: BASIC realm=“Sonatype Nexus Repository Manager“)

时间2025-04-30 14:57:06分类IT科技浏览6651
导读:场景: 执行npm install时提示Unable to authenticate...

场景:

执行npm install时提示Unable to authenticate

Password:

Email: (this IS public) xx@qq.com

Logged in as uploader on http://192.168.xx.xxx:8074/repository/npm-internal/.

PS D:\GitworkspaceUi\gisquest-cloud-ui-workcenter> npm install

npm ERR! code E401

npm ERR! Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"

npm ERR! A complete log of this run can be found in:

npm ERR!     C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2023-01-04T06_05_27_843Z-debug.log     

PS D:\GitworkspaceUi\gisquest-cloud-ui-workcenter> 

问题原因:

执行npm install到仓库拉取代码时需要认证              ,现在是认证不通过                    ,因此报错 

现象:

浏览器直接访问仓库        ,然后使用公司给的账号和密码登录是正常的           ,说明账号密码是正确的

http://192.168.xx.xxx:8074/repository/npm-internal/.

解决方法:

先执行npm config list,找到.npmrc的位置

PS D:\GitworkspaceUi\gisquest-cloud-ui-workcenter> npm config list

; cli configs

metrics-registry = "http://192.168.xxx.xxx:8073/repository/npm-all/"

scope = ""

user-agent = "npm/6.14.12 node/v14.16.1 win32 x64"

; userconfig C:\Users\Administrator\.npmrc

 方法一(网上的仅供参考):

打开后大概如下效果

 删掉第二行

 //192.168.xx.xx:8073/repository/npm-all/:_authToken=NpmToken.1ee55b58-d164-3b43-a731-xxxxxx

 重新执行登录

npm login --registry=http://192.168.xx.xxx:8073/repository/npm-internal/

  方法二:直接删掉.npmrc

npm config set registry http://192.168.xx.xxxx:8073/repository/npm-all/ 

npm config set //192.168.xx.xxx:8073/repository/npm-all/:_authToken=NpmToken.1ee55b58-d164-3b43-a731-xxxxx

说明:上面第一条命令是注册仓库的位置                   ,第二条是仓库的的认证token

这里的token是从同事(他那里是正常).npmrc文件中复制过来的

然后执行npm install正常了 

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
猴子补丁原理(猴子补丁) aras是什么软件(askservice.exe是什么进程?askservice.exe有没有病毒?)