[解决]npm ERR! publish Failed PUT 403

使用命令 npm publish 发布一个包时,或有如下报错:

...
npm ERR! publish Failed PUT 403
npm ERR! code E403
npm ERR! no_perms Private mode enable, only admin can publish this module:...
...

解决过程如下:

1. 检查仓库是否被设成了淘宝镜像库
npm config get registry

https://registry.npm.taobao.org/

2. 如是,则设回原仓库
npm config set registry=http://registry.npmjs.org
3. 登录账号(如未登录)
npm login

Username: username

Password:
*

Email: (this IS public)

foo@bar.com Logged in as username on
http://registry.npmjs.org/.

4. 再次发布
npm publish
5. 如发布成功,则再次将仓库地址设为淘宝镜像地址
npm config set registry=https://registry.npm.taobao.org/
    原文作者:aeiou
    原文地址: https://segmentfault.com/a/1190000014800794
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞