npm publish相关问题记录

npm ERR! code E403 问题

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

  • npm config get registry
     

    然后发现是淘宝镜像库

2. 将仓库设置为原仓库

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

3. npm publish再次发布

npm ERR! 402 Payment Required - PUT https://registry.npmjs.org/@xxx%2fxxx - You must sign up for private packages 问题

这个当你的包名为@your-name/your-package时才会出现,原因是当包名以@your-name开头时,npm publish会默认发布为私有包,但是 npm 的私有包需要付费,所以需要添加如下参数进行发布:

npm publish --access public
  • npm ERR! E426

npm ERR! code E426 npm ERR! 426 Upgrade Required - PUT http://registry.npmjs.org/formats_date npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Administrator\AppData\Local\npm-cache\_logs\2021-11-25T06_55_02_155Z-debug.log error Command failed with exit code 1.

解决方案:

各种尝试还是报错,各种搜索终于找到原因了,修改镜像的时候需要使用 https,运行以下命令就可以解决了:

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

你可能感兴趣的:(npm,坑,npm,node.js,vue.js)