我剛剛開始與npm,並據我所知,npm install
命令應自動更新package.json
文件,但與我不幸的是,它不。爲什麼我的package.json沒有通過npm install進行更新?
我在OSX和一個叫npmtest我新的目錄做了以下內容:
$ ls # let's first confirm the folder is empty
$
$ npm init --y
Wrote to /Users/kramer65/Downloads/npmtest/package.json:
{
"name": "npmtest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
我再裝下劃線:
$ npm install underscore
[email protected] /Users/kramer65/Downloads/npmtest
└── [email protected]
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
,這似乎是安裝罰款:
$ ls -l
total 8
drwxr-xr-x 3 kramer65 staff 102 Oct 18 17:47 node_modules
-rw-r--r-- 1 kramer65 staff 221 Oct 18 17:47 package.json
不幸npm list
抱怨說它不在package.json
文件中wi TH的extraneous
標誌:
$ npm list
[email protected] /Users/kramer65/Downloads/npmtest
└── [email protected] extraneous
npm ERR! extraneous: [email protected] /Users/kramer65/Downloads/npmtest/node_modules/underscore
,我可以確認:
$ cat package.json
{
"name": "npmtest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
的問題是;爲什麼它不是輸入在package.json
文件中?不應該自動發生?我在這裏做錯了什麼?歡迎所有提示!
'npm install'不更新'package.json'文件,'npm install *模塊名稱* --save'更新'json'包。 – ZombieChowder
@ZombieChowder - 啊,謝謝。你可以添加一個答案,以便我可以接受它嗎? – kramer65