使用命令 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/