创建npm
包
创建
npm
工程- 新建一个工程文件夹,
- 在工程文件夹中新建一个
index.js
文件 - 终端进入工程文件夹目录,终端执行
npm init
初始化1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27npm init
终端会提示如下信息
package name: 项目名称,默认当前文件夹名称
version: 版本号
description: 描述
entry point: 入口文件夹
test command: 测试命令
git repository: git仓库地址
keywords: 关键词
author: 作者
license: 许可证
About to write to /Users/quokka/Desktop/Quokka/Projects/yunjv-code-specification/package.json:
# {
"name": "yunjv-code-specification",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Yunjv",
"license": "ISC"
}
# Is this OK? (yes)
可一路回车,最后输入yes即可
发布 npm 包
- 注册 npm 账号
- 终端工程目录下执行
1
2
3
4npm login
Username: 输入用户名
Password: 不会显示,输入完回车
Email: 邮箱 - 开始发布
1
npm publish
npm
源需要是https://registry.npmjs.org/
,否则发布后在npmjs.org
中查不到
在
npmjs.com
验证是否创建成功