发布自己的npm包 ¶
前提 ¶
先注册NPM和github账号
创建模版 ¶
- 选择模版
sh
npm craete cvjs
- 选择 js 或者 ts
- 选择 npm 包模版, Lib库模式、UI组件模式
开发 ¶
打包发布 ¶
初次发布 - 常规包 ¶
# 先切换镜像源
npm config set registry https://registry.npmjs.org/
# 登录
npm login
# 输入npm账号名
# 输入npm密码
# 输入npm邮箱
# 登录成功,会显示:
Logged in as 你的名字 on https://registry.npmjs.org/.
# 发布 常规包
# npm publish
# 切换回淘宝镜像源
npm config set registry https://registry.npmmirror.com/
发布 - 作用域包(组织、机构包) ¶
# 先切换镜像源
npm config set registry https://registry.npmjs.org/
# 登录
npm login
# 发布 @作用域包,(需要在npm创建对应组织或者作用域)
npm publish --access=public
# 切换回淘宝镜像源
npm config set registry https://registry.npmmirror.com/
更新发布 ¶
- 注:npm version patch为版本加1
npm config set registry https://registry.npmjs.org/
npm version patch
npm login
npm publish --access=public
npm config set registry https://registry.npmmirror.com/
删除\撤销发布 ¶
# 撤销
# npm unpublish --force
# 删除整个包
# npm unpublish --force @10yun/ctocode-js-utils
# 删除指定的版本
# npm unpublish --force @10yun/ctocode-js-utils@1.0.0
# 作废
npm deprecate @10yun/ggui-pc-editor-code ' 请使用新版, @10yun/cv-pc-editor-code '
npm deprecate @10yun/ggui-pc-editor-json ' 请使用新版, @10yun/cv-pc-editor-json '
发布线上 ¶
- https://blog.csdn.net/zyg1515330502/article/details/81112653 如何使用npm发布自己的npm包
- https://zhuanlan.zhihu.com/p/42419082 如何发布一个npm应用?
- https://www.jianshu.com/p/6407383a6099 docker搭建私有npm服务器
- https://www.dazhuanlan.com/2019/12/09/5dee4df892558/ 使用 Docker 搭建私有NPM仓库 | 大专栏