登录失败
错误信息
npm notice Log in on http://localhost:8081/repository/npm-hosted
Username: admin
Password:
npm error code E401
npm error Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"
npm error A complete log of this run can be found in: /Users/zouni/.npm/_logs/2025-10-30T03_25_39_157Z-debug-0.log
解决:
# 清除当前仓库的认证信息
npm config delete //localhost:8081/repository/npm-private-hosted/:_authToken
npm config delete //localhost:8081/repository/:_authToken
# 重新设置仓库源(确保地址正确)
npm config set registry http://localhost:8081/repository/npm-private-hosted/
# 重新登录
npm login --registry=http://localhost:8081/repository/npm-private-hosted/