npm包发布流程

npm包发布流程

最后修改时间:3 months ago

# 1.写好自己的代码

# 2.代码根目录

npm init
1

# 3.按照提示完成类似以下内容的输入

package name: (test-projects)
version: (1.0.0)
description: this is my test-project for npm publish
entry point: (index.js)
test command: hello world.
git repository: (https://github.com/loushengyue/test-projects.git)
keywords: test test-pro test-projects
author: loushengyue
license: (ISC)
1
2
3
4
5
6
7
8
9

# 4.注册npm账号

# 5.首次登录

$ npm login
Username: xxxxxx
Password: xxxxxx
Email:xxxxxx
Logged in as loushengyue on https://registry.npmjs.org/.
1
2
3
4
5

# 6.发布npm包

npm publish --access=public

# 7.包更新

改完pack.json后

$ npm publish
npm notice
npm notice package: sunyifangx@1.0.1
npm notice === Tarball Contents ===
npm notice 556B   package.json
npm notice 28.6kB aa.png
npm notice 5.1kB  README.md
npm notice === Tarball Details ===
npm notice name:          test-pro-xxxx
npm notice version:       1.0.1
npm notice package size:  30.7 kB
npm notice unpacked size: 34.2 kB
npm notice shasum:        aa3736f226f22702dcdf64fe56c
npm notice integrity:     sha512-p5OT3ONm+BgIJ[...]it7/CMjELwqNg==
npm notice total files:   3
npm notice
+ sunyifangx1.0.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

# 8.卸载删除

npm unpublish 依赖包名称 --force
1

# tips

在根目录写个index.js(默认)把想导出的组件/js文件放进去即可 如果遇到名称相同会报错

npm ERR! publish Failed PUT 403
npm ERR! code E403
npm ERR! Package name too similar to existing packages; try renaming your package to '@loushengyue/test-projects' and publishing with 'npm publish --access=public' instead : test-projects

1
2
3
4

改一下pack.json里面的name即可

- 全文完 -

留下一条留言?
默认颜色

主题颜色

标准颜色

更多颜色...