license
- 开源许可证
- 所有的包又应该有 license,以便让使用它的人知道是在什么授权下使用此包
- 如果是公司内部的包或者不想别人用的包,应该赋值为
UNLICENSE
homepage
代码托管库
"homepage":"https://your-package.org"repostory
"repostory": {
"type":"git",
"url":"https://github.com/user/repo.git"
},
"repostory": "github:user/repo",files
指定包含在项目中的文件,可以是:
- 单独的文件
- 整个文件夹
- 通配符
"files":[
"filename.js",
"directory/",
"glob/*.{js,json}"
]main
项目入口文件,通常是CommonJs规范的入口文件
"main":"filename.js"bin
随着项目一起被安装的可执行文件。
dependencies
"dependencied" : {
"vue": "^2.0.0"
}这是开发版和发布版都需要的依赖。
devDenpendencies
仅仅是开发阶段需要用到的依赖。
peerDependencies
平行依赖
一般用于:开发 A 包给主项目 main 用,A 包引用到了 B 包,主项目也用到了 B 包。此时,A 包引用 B 包应使用peerDependencies而不是dependencies。
如element-ui:
-
当
elementUI直接在dependencies引用vue的时候,就会出现 2 个vue模块。my-project | - node_modules | - vue | - element-ui | - node_modules | - vue -
但是当在
peerDependencies引用vue的时候,就会只有一个vue模块。my-project | - node_modules | - vue | - element-ui
resolutions
解决版本依赖冲突(给yarn用的)
当main项目和main项目引用的的依赖A,同时依赖的B的两个不同的版本。这个时候就可以用resoutions去解决。在resolution里面指定B的版本号,main项目和A都会使用resolution里设置的B版本。
参考:
engines
指定你的包客户必须使用的版本,如node版本(通过检查process.versions),yarn版本。
os
同上,检查操作系统(通过检查process.platform)
cpu
同上,(process.arch)
private
如果不想发布到包管理器,设置为true