发布包
2023年05月26日
一、发布包
package.json 完整配置
{
"name": "bolawen-cli",
"version": "1.0.6",
"repository": "git@github.com:bolawen/cli.git",
"author": "zhangwenqiang <335303383@qq.com>",
"license": "MIT",
"bin": {
"bolawen": "bin/bolawen.js"
},
"dependencies": {
"chalk": "^4.1.1",
"commander": "6.0.0",
"download-git-repo": "^3.0.2",
"ejs": "^3.1.6",
"inquirer": "^8.1.0",
"log-symbols": "4.0.0",
"ora": "^5.4.1"
}
}
1.1、配置版本
通过package.json
配置NPM
发布的版本
"version": "1.0.6",
1.2、配置仓库地址
"repository": "git@github.com:bolawen/cli.git",
1.3、切换 NPM 镜像
执行npm login
命令之前,必须切回npm
源地址,也就是说不可以用taobao 镜像
、cnpm 镜像
登录 npm
。否则报以下错误:
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.
1.4、登录 NPM 账户
登录命令: npm login
- 用户名:
bolawen
- 密码:
*****
- 邮箱:
335303383@qq.com
1.5、发布 NPM 新包
发布命令: npm publish