1. 程式人生 > >npm ERR! publish Failed PUT 403

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)
[email protected] Logged in as username on  http://registry.npmjs.org/.

4. 再次釋出

npm publish

5. 如釋出成功,則再次將倉庫地址設為淘寶映象地址

npm config set registry=https://registry.npm.taobao.org/