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


在登录自有npm库的时候发现输入正确的账号密码,依然会报错

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

在尝试网上提供方法后没有得到解决,
然后尝试输入一个错误的密码,发现得到的结果相同,猜想本地配置有问题。
所以需要做的就是还原npm配置。
我这里通过直接更改npm配置文件达到目的

首先打开 finder, 按下command + shift + . 显示隐藏文件,找到 .npmrc

打开它

;;;;
; npm userconfig file
; this is a simple ini-formatted file
; lines that start with semi-colons are comments.
; read `npm help config` for help on the various options
;;;;

registry=http://nexus.git.xxx.cn/repository/xxx-npm/   
//nexus.git.xxx.cn/repository/xxx-npm/:_authToken=NpmToken.75611ad7-890b-3682-996b-72d0d69dab9
home=https://yarnpkg.com

;;;;
; all options with default values
;;;;

中间那三行,只需要保留registry=http... 就行了。
再次执行 npm login

Logged in as cddevelop on http://nexus.git.xxx.cn/repository/xxx-npm/.

成功了~


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM