經過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