NodeJS中 package.json 解析

來源:互聯網
上載者:User

標籤:des   blog   http   io   ar   os   java   sp   strong   

package.json 中包含各種所需模組以及項目的配置資訊(名稱、版本、許可證等)meta 資訊。

 

包含可配置項

  • name 名稱
  • 應用描述 description
  • 版本號碼 version
  • 應用的配置項 config
  • 作者 author
  • 資源倉庫地址 respository
  • 授權方式 licenses
  • 目錄 directories
  • 應用入口檔案 main
  • 命令列檔案 bin
  • 項目應用運行相依模組 dependencies
  • 項目應用開發環境依賴 devDependencies
  • 運行引擎 engines
  • 指令碼 script

簡單模式

==========================

{       name: "myApp",    version :"0.0.1" }

  

 

完整模式

===========================

 {    "name": "myApp",    "version": "0.0.0",    "author" : "simple",    "description" : "Nodejs Package json介紹",    "keywords" : "javascript, nodejs",    "respository" : {        "type" :"git",        "url" :"http://path/to/url"    },    "bugs" : {        "url" : "http://path/to/bug",        "email" : "[email protected]"    },    "contributors" : [    {"name" : "zhangsan", "email" : "[email protected]"     ]    "license" : "MIT",    "engines" : { "node" : "0.10.x"},    "script" : {        "start" : "node index.js"    },    "private": true,    "scripts": {    "start": "node ./bin/www"    },    "dependencies": {        "express": "~4.9.0",        "body-parser": "~1.8.1",        "cookie-parser": "~1.3.3",        "morgan": "~1.3.0",        "serve-favicon": "~2.1.3",       "debug": "~2.0.0",        "jade": "~1.6.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"    }}

  

1.scripts

運行指定指令碼命令。

 

2.

npm install express --save

npm install express --save-dev

上面代碼錶示單獨安裝express模組,

--save參數表示將該模組寫入dependencies屬性,

--save-dev表示將該模組寫入devDependencies屬性。

3.關於指定版本號碼

(1)波浪號~(tilde)+指定版本:比如~1.2.2,表示安裝1.2.x的最新版本(不低於1.2.2),但是不安裝1.3.x,也就是說安裝時不改變大版本號碼和次要版本號碼。 

 

NodeJS中 package.json 解析

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.