发布npm包报错: 403 Forbidden

 出现这个问题是因为当前设置的是cnpm 登录到的是cnpm,所以需要切换回来

可以输入一下命令查看当前的登录源:

npm config get registry

淘宝源,需要切回到npmjs源,输入以下命令:

npm config set registry=http://registry.npmjs.org

npm发布

npm publish

报错:

npm ERR! code E403
npm ERR! 403 403 Forbidden - PUT https://registry.npmjs.org/lanke-template-h5 - Forbidden
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy.

npm ERR! A complete log of this run can be found in:
npm ERR!     D:NodeJS
ode_cache\_logs2020-11-27T03_42_41_070Z-debug.log

在检查完自己是否已登录,如果已经登录,那么查看一下关联npm 的邮箱是否有验证过,我的就是因为没有验证邮箱所以才会报这个错。

验证成功之后再 npm publish就可以了

5. 如发布成功,则再次将仓库地址设为淘宝镜像地址
npm config set registry=https://registry.npm.taobao.org/

原文地址:https://www.cnblogs.com/lyt0207/p/14056741.html