npm install 提示Unable to authenticate, need: BASIC realm=“Sonatype Nexus Repository Manager“
场景:
执行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:GitworkspaceUigisquest-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:UsersAdministratorAppDataRoaming pm-cache\_logs2023-01-04T06_05_27_843Z-debug.log
PS D:GitworkspaceUigisquest-cloud-ui-workcenter>
问题原因:
执行npm install到仓库拉取代码时需要认证,现在是认证不通过,因此报错
现象:
浏览器直接访问仓库,然后使用公司给的账号和密码登录是正常的,说明账号密码是正确的
http://192.168.xx.xxx:8074/repository/npm-internal/.
解决方法:
先执行npm config list,找到.npmrc的位置
PS D:GitworkspaceUigisquest-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:UsersAdministrator.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正常了
相关文章
- Python中的函数与方法 以及Bound Method和Unbound Method
- 一文贯通python文件读取
- Python 中的异步编程:Asyncio
- 7个你现在就该学习Python的理由
- 提高Python运行效率的六个窍门
- Python数据科学:神经网络
- 一篇文章看懂大数据分析就业前景及职能定位
- R和Python中的文本挖掘:8个入门小贴士
- 告诉你为什么Python有点慢,但我却无所谓?
- 专注学习DevOps编程语言Top 5推荐
- Python发送邮件脚本
- Python多进程并行编程实践: mpi4py 的使用
- Python语言在未来的发展前景
- Python vs Ruby: 谁是最好的 web 开发语言?
- Python对Ruby:谁在Web开发领域更胜一筹?
- Python一行代码完成并行任务
- Python开发者2017应该关注的七个类库
- python爬虫入门基本知识
- 在终端中优雅地编写Python
- Python机器学习实战:信用卡欺诈检测