发包
创建包
- 新建目录
- 创建文件
package.json
index.js
README.md
- 配置
package.json
index.js
文件1
2
3
4
5
6
7
8
9
10
11
12
13{
"name": "包名",
"version": "1.0.0", // 版本
"description": "描述",
"main": "index.js", // 入口文件
"author": "作者",
"license": "ISC", // 证书
"keywords": ['关键字1', '关键字2'],
"publishConfig": {
"access": "public", // 公共包
"registry": "https://registry.npmjs.org/"
}
}1
2
3module.exports = {
a: 'a',
};
发布
1 | // 切换源 |
发布带scope命名空间的包
- 新建 组织
- 修改
package.json
name 属性1
2
3{
"name": "@[空间名]/[包名]"
} - 发布
1
npm publish
更新
1 | npm version patch // 1.0.0 => 1.0.1 |
1 | npm publish |
删除
1 | npm deprecate 包名 |