我刚刚开始与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