经过npm init 建立 package.json文件javascript
参数:java
name:项目名字node
version: 版本号git
description: 项目介绍github
main: 项目的入口文件shell
scripts: npm提供给咱们运行shell命令的入口express
author:做者npm
license:标注咱们项目的许可证权限,若是不想开源({"license":"UNLICENSED"}或{"private":true})json
dependencies:项目运行时必要依赖,小程序
peerDependencies: 针对特定版本开发
devDependencies:项目开发时所需依赖
homepage:项目主页的网址
files:将软件包做为依赖项安装时要包含的条目
{ "name": "Hello World", //name属性就是你的模块名称 "version": "0.0.1", //version必须能够被npm依赖的一个node-semver模块解析 "author": "张三", //"author"是一个码农 "description": "第一个node.js程序", //一个描述,方便别人了解你的模块做用,搜索的时候也有用。 "mian":"index.js", //main属性指定了程序的主入口文件. "keywords":["node.js","javascript"], //一个字符串数组,方便别人搜索到本模块 "repository": { //指定一个代码存放地址,对想要为你的项目贡献代码的人有帮助。 "type": "git", "url": "https://path/to/url" }, "license":"MIT", //你应该为你的模块制定一个协议,让用户知道他们有何权限来使用你的模块,以及使用该模块有哪些限制,如BSD-3-Clause 或 MIT之类的协议 "engines": {"node": "0.10.x"}, "bugs":{ //填写一个bug提交地址或者一个邮箱,被你的模块坑到的人能够经过这里吐槽 "url":"https://github.com/luoshushu", "email":"bug@example.com" }, "contributors":[{"name":"李四","email":"lisi@example.com"}], // "contributors"是一个码农数组。 "scripts": { //指定了运行脚本命令的npm命令行缩写。好比:输入npm run start时,所要执行的命令是node index.js。 "start": "node index.js" }, "dependencies": { //指定了项目运行所依赖的模块 "express": "latest", "mongoose": "~3.8.3", "handlebars-runtime": "~1.0.12", "express3-handlebars": "~0.5.0", "MD5": "~1.2.0" }, "devDependencies": { //指定项目开发所须要的模块 "bower": "~1.2.8", "grunt": "~0.4.1", "grunt-contrib-concat": "~0.3.0", "grunt-contrib-jshint": "~0.7.2", "grunt-contrib-uglify": "~0.2.7", "grunt-contrib-clean": "~0.5.0", "browserify": "2.36.1", "grunt-browserify": "~1.3.0", } }
小程序 也可能用到这个
转:https://www.jianshu.com/p/9879273a09a1
https://www.jianshu.com/p/68f2608c7976