npm发包技巧

一点 npm 发包技巧

使用 nrm 管理源

今天发布 npm 包的时候一直提示

1
2
npm ERR! code E403
npm ERR! 403 Forbidden - PUT https://registry.npm.taobao.org/@xaviershi%2fvue-cli-plugin-xaviershi - [no_perms] Private mode enable, only admin can publish this module

经过查找是因为使用 taobao 源的原因导致的。
首先npm i nrm,nrm ls查看源,nrm use使用源

发布带作用域的包

  1. npm init --scope=<作用域名>
  2. npm publish --access public
  3. 好像只能写自己账号名字的作用域,不过可以交钱创建组织

npm 撤销发布的包

npm unpublish 作用域名@包名@版本号,只能撤销 24 小时内发布的包。

参考资料

【npm】利用 npm 安装/删除/发布/更新/撤销发布包
2018 年了,你还是只会 npm install 吗?
npm 发布以@开头命名的 public 公有包!!!
使用 npm 作用域管理发布包

Author: XavierShi
Link: https://blog.xaviershi.com/2018/12/20/npm发包技巧/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.