我刚开始使用 npm,据我所知,该npm install
命令应该自动更新package.json
文件,但不幸的是我没有。
我在 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
带有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 *module name* --save
更新json
包。希望有帮助。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句