1. 程式人生 > >關於package.json

關於package.json

min char depend str ins serve 2.6 scripts pack

---恢復內容開始---

用angular開發前臺項目,每個項目的根目錄下面,都有一個package.json文件,

定義了項目所需要的各種模塊依賴,和項目的配置信息(比如名稱,版本號等信息,有點像maven)。當我們執行npm install 命令時,就會根據這個配置文件,自動下載所需要的模塊,也就是配置項目所需要的運行和開發環境。

for example,下面是一個最簡單的package.json文件,只定義兩項數據:項目名稱和版本

{
    “name” : "xxx",
    "version" : "0.0.0", 
}

說明:package.json文件內部就是一個json對象,該對象的每一個成員就是當前項目的一項設置,

name就是項目名稱,version是版本(版本寫法遵守“大版本.次要版本.小版本”的格式)。

下面是一個完整的package.json文件。

{
  "name": "cmdb-front",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private
": true, "dependencies": { "@angular/animations": "^4.0.0", "@angular/common": "^4.0.0", "@angular/compiler": "^4.0.0", "@angular/core": "^4.0.0", "@angular/forms": "^4.0.0", "@angular/http": "^4.0.0", "@angular/platform-browser": "^4.0.0", "@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0", "bootstrap": "^4.0.0-alpha.6", "classlist.js": "^1.1.20150312", "core-js": "^2.4.1", "d3": "^4.10.0", "echarts": "^3.8.5", "font-awesome": "^4.7.0", "intl": "^1.2.5", "jquery": "^3.2.1", "ng2-cookies": "^1.0.12", "primeng": "^4.2.2", "rxjs": "^5.1.0", "zone.js": "^0.8.4" }, "devDependencies": { "@angular/cli": "1.2.6", "@angular/compiler-cli": "^4.0.0", "@angular/language-service": "^4.0.0", "@types/jasmine": "~2.5.53", "@types/jasminewd2": "~2.0.2", "@types/node": "~6.0.60", "codelyzer": "~3.0.1", "jasmine-core": "~2.6.2", "jasmine-spec-reporter": "~4.1.0", "karma": "~1.7.0", "karma-chrome-launcher": "~2.1.1", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^1.2.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.1.2", "ts-node": "~3.0.4", "tslint": "~5.3.2", "typescript": "~2.3.3" } }

下面就具體說明package..json文件中各個字段的意思。

---恢復內容結束---

關於package.json