定義了項目所須要的各類模塊,以及項目的配置信息(好比名稱、版本、許可證等元數據)vue
npm install 命令根據這個配置文件,自動下載所需的模塊,也就是配置項目所需的運行和開發環境。node
package.json 文件能夠手工編寫,也能夠使用npm init命令自動生成webpack
package-lock.json 是用來鎖定安裝時的包的版本號,而且須要上傳到git,以保證其餘人在npm install時你們的依賴能保證一致。ios
//package.json
{
"name": "vv", //項目名稱
"version": "0.0.0", //項目版本(遵照「大版本.次要版本.小版本」的格式)
"description": "A Vue.js project", //名稱
"author": "",
"private": true,
"scripts": { //npm命令行縮寫
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"start": "npm run dev",
"build": "node build/build.js"
},
"dependencies": { //項目運行所依賴的模塊
"axios": "^0.18.0",
"echarts": "^4.1.0",
"echarts-wordcloud": "^1.1.3",
"element-ui": "^2.3.8",
"less": "^3.9.0",
"less-loader": "^4.1.0",
"sass": "^1.3.2",
"vue": "^2.5.2",
"vue-axios": "^2.1.1",
"vue-resource": "^1.5.0",
"vue-router": "^3.0.1"
},
"devDependencies": { //項目開發所須要的模塊
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^7.1.1",
"vue-loader": "^13.3.0",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.5.2",
"webpack": "^3.6.0",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^2.9.1",
"webpack-merge": "^4.1.0"
},
"peerDependencies": { //供插件指定其所須要的主工具的版本
"chai": "1.x"
},
"bin": { //指定各個內部命令對應的可執行文件的位置
"someTool": "./bin/someTool.js"
},
"config" : { "port" : "8080" }, //添加命令行的環境變量
"engines": { //項目所須要的node.js版本
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
},
"browserslist": [ //設置項目的瀏覽器兼容狀況
"> 1%",
"last 2 versions",
"not ie <= 8"
]
複製代碼
更多字段請參考(segmentfault.com/a/119000001…git