每一個包須要在其頂層目錄下包含一個package.json文件,該文件不只是包的說明,也影響npm安裝包時的配置選項javascript
更多參數詳見參考文檔https://npmjs.org/doc/json.html html
{ "name": "cordova", "version": "3.0.4", "preferGlobal": "true",//若是安裝包是做爲命令行應用程序,應該全局模式安裝,若是用戶使用本地模式安裝,則警告提醒 "description": "Cordova command line interface tool", "main": "cordova", //表示Node.js在調用某個模塊的時候,將尋找main指向的路徑做爲模塊的接口,在這裏Node將尋找同目錄下的cordova文件,並嘗試從它那加載模塊; //若是沒有cordova,Node仍是會嘗試尋找cordova.js或者cordova.node做爲包的接口。 //至關於這是初始化函數,返回此文件中export的對象內容 "engines":{ "node":">=0.9.9" //指定使用node的版本 }, "engineStrict":true, //若是肯定模塊只能能在engines 參數指定的版本正常工做,則設置此參數 "bin": { "cordova": "./bin/cordova" //用戶在命令行輸入時,解析參數執行此文件
cordova文件 java
#!/usr/bin/env node var CLI = require('../src/cli'); new CLI(process.argv);
}, "scripts": { "test": "jasmine-node --color spec" //存儲一些默認運行命令腳本信息 //cordova test 執行 jasmine-node --color spec }, "repository": { "type": "git", "url": "https://git-wip-us.apache.org/repos/asf/cordova-cli.git" // 存儲位置 }, "bugs":{ "url" : "https://issues.apache.org/jira/browse/CB", "email" : "dev@cordova.apache.org" }, "keywords": [ "cordova", "client", "cli" ], "dependencies": { "colors":">=0.6.0", "elementtree":"0.1.3", "plugman":"0.10.0", "plist":"0.4.x", "xcode":"0.5.1", "express":"3.0.0", "shelljs":"0.1.2", "ncallbacks":"1.0.0", "request":"2.22.0", "ripple-emulator":"0.9.18", "semver":"1.1.0", "glob":"3.2.x", "follow-redirects":"0.0.x", "prompt":"0.2.7", "tar":"0.1.x", "open": "0.0.3", "npm":"1.3.x", "optimist":"0.6.0" }, /*依賴模塊列表 version 版本號必須精確匹配 >version 必須大於當前版本號 >=version 必須大於等於 <version 小於 <=version 小於等於 ~1.2.3 := >=1.2.3-0 <1.3.0-0 1.3.0-beta 不知足 ~1.2.3支持條件 ~1.2 := >=1.2.0-0 <1.3.0-0 以1.2開始的版本 1.2.x := >=1.2.0-0 <1.3.0-0 以1.2開始的版本 ~1 := >=1.0.0-0 <2.0.0-0 以1開始的版本 1.x := >=1.0.0-0 <2.0.0-0 以1開始的版本 1.2.x 1.2.0, 1.2.1,等,不超過 1.3.0 http://... 見連接地址 * 匹配任意版本 "" 匹配任意版本 version1 - version2 等價於 >=version1 <=version2. range1 || range2 range1 或 range2都可 git... 見git地址 user/repo見 'GitHub ' 地址 */ "devDependencies": { "jasmine-node":"1.8.x" }, / /開發階段使用的模塊,在用戶使用時不須要依賴的模塊 "author": "Anis Kadri", //開發者 "contributors": [ {"name": "Brian LeRoux","email": "b@brian.io"}, {"name": "Fil Maj", "email": "maj.fil@gmail.com"}, {"name": "Mike Reinstein", "email":"reinstein.mike@gmail.com"}, {"name": "Darry Pogue", "email":"darryl@dpogue.ca"}, {"name": "Michael Brooks", "email":"michael@michaelbrooks.ca"}, {"name": "Braden Shepherdson", "email":"braden@chromium.org"}, {"name": "Gord Tanner", "email":"gtanner@gmail.com"}, {"name": "Tim Kim", "email": "timk@adobe.com"}, {"name": "Benn Mapes", "email": "Benn.Mapes@gmail.com"}, {"name": "Michael Wolf", "email": "Michael.Wolf@Cynergy.com"}, {"name": "Andrew Grieve", "email": "agrieve@chromium.org"}, {"name": "Bryan Higgins", "email": "bhiggins@blackberry.com"}, {"name": "Don Coleman", "email": "dcoleman@chariotsolutions.com"}, {"name": "Germano Gabbianelli", "email": "tyron.mx@gmail.com"}, {"name": "Ian Clelland", "email": "iclelland@chromium.org"}, {"name": "Lucas Holmqust", "email": "lholmqui@redhat.com"}, {"name": "Matt LeGrand", "email": "mlegrand@gmail.com"}, {"name": "Michal Mocny", "email": "mmocny@gmail.com"}, {"name": "Sam Breed", "email": "sam@quickleft.com"}, {"name": "Tommy-Carlos Williams", "email": "tommy@devgeeks.org"}, {"name": "Rubén Norte", "email": "rubennorte@gmail.com"} //貢獻者人員信息 ], "license": "Apache version 2.0" }