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

npm ERR! publish Failed PUT 403

解决过程:

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

npm config get registry

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

npm login 或者添加用户 npm adduser

4. 再次发布

npm publish

5. 如发布成功,则再次将仓库地址设为淘宝镜像地址

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

6,期间又遇到了一个错误403 (没有遇到的话不用看)

npm ERR! publish Failed PUT 403

这是是因为没有认证邮箱,要去你填写的邮箱里认证一下。



相关文章: