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/.

成功了~

posted @ 2020-06-29 10:47  lisiyuan  阅读(17563)  评论(0编辑  收藏  举报