package.json
每一個項目都要有一個
package.json
檔案(包描述檔案,就像産品的說明書一樣)
這個檔案可以通過
npm init
自動初始化出來
D:\code\node中的子產品系統>npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.
See `npm help json` for definitive documentation on these fields
and exactly what they do.
Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.
Press ^C at any time to quit.
package name: (node中的子產品系統)
Sorry, name can only contain URL-friendly characters.
package name: (node中的子產品系統) cls
version: (1.0.0)
description: 這是一個測試項目
entry point: (main.js)
test command:
git repository:
keywords:
author: xiaochen
license: (ISC)
About to write to D:\code\node中的子產品系統\package.json:
{
"name": "cls",
"version": "1.0.0",
"description": "這是一個測試項目",
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "xiaochen",
"license": "ISC"
}
Is this OK? (yes)
- 建議每個項目的根目錄下都有一個
檔案package.json
- 建議執行
的時候都加上npm install 包名
選項,目的是用來儲存依賴資訊--save