在登錄自有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/.
成功了~