如何发布npm包

发布于: 5/25/2022 阅读大约需要0分钟

前提: 已有项目,已有npm账号

  1. 登录到npm
npm login


登录到特定仓库需要添加 --registry 参数


本地发布

yalc

  1. 安装环境
npm install yalc -g
  1. 发布依赖
yalc publish
  1. 添加本地依赖
yalc add local-repo
  1. 更新依赖
yalc update
  1. 清除依赖
yalc remove
# 全部移除
yalc remove --all

verdaccio

  1. 安装环境
npm install --global verdaccio
  1. 运行verdaccio
  2. 登录npm:  npm adduser --registry [<http://localhost:4873/>](<http://localhost:4873/>)
  3. 打开本地 http://localhost:4873/
  4. 发布: npm publish --registry [<http://localhost:4873/>](<http://localhost:4873/>)