npm发布自己的包时,提示 [FORBIDDEN] Public registration is not allowed解决办法

154 阅读1分钟

描述

发布包过程可能会遇到很多问题,比较无语的是403 Forbidden如下

npm ERR! code E403
npm ERR! 403 403 Forbidden - PUT https://registry.npmmirror.com/-/user/org.couchdb.user:xxxxxxxx - [FORBIDDEN] Public registration is not allowed
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, or
npm ERR! 403 on a server you do not have access to.
 
npm ERR! A complete log of this run can be found in:

提示内容如上

问题的原因是你的NPM使用了镜像地址.

解决方法是:

全局安装也就是node的源管理器

安装方法:终端或者CMD中输入

npm install -g nrm

安装好以后 输入

nrm use npm

切换到npm官方的源地址

记得每次npm publish的时候也都要切换回来.正常安装包的时候可以

nrm use taobao切换到淘宝镜像源

image.png