快速安裝package.json
npm init -y
會得到
// package.json
{
"name": "node-test",
"version": "1.0.0",
"description": "專案在做什麼的說明",
"main": "demo.js",
"dependencies": {},
"devDependencies": {},
"scripts": {
"test": "echo \\"Error: no test specified\\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
dependencies ⇒ 都會使用到的套件
devDependencies ⇒ 正式環境需要的套件
套前版本前面的^ ⇒
^代表每次更新時需大於當前版本才會被更新,但有可能因為套件改動過大導致專案出問題
ex:
// package.json
"dependencies": {
"colors": "^1.4.0"
}
package-lock.json為記錄當時下載的套件版本,鎖住版號避免更新到最新版本