Reputation: 53873
I'm just starting out with npm, and as far as I understand the npm install
command should automatically update the package.json
file, but with me it unfortunately doesn't.
I'm on OSX and in a new dir called npmtest I did the following:
$ 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"
}
I then installed underscore:
$ npm install underscore
[email protected] /Users/kramer65/Downloads/npmtest
└── [email protected]
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
which seems to be installed fine:
$ 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
unfortunately npm list
complains that it's not in the package.json
file with the extraneous
flag:
$ npm list
[email protected] /Users/kramer65/Downloads/npmtest
└── [email protected] extraneous
npm ERR! extraneous: [email protected] /Users/kramer65/Downloads/npmtest/node_modules/underscore
Which I can confirm:
$ 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"
}
The question is; why isn't it entered in the package.json
file? Shouldn't that go automatically? What am I doing wrong here? All tips are welcome!
Upvotes: 0
Views: 400
Reputation: 1204
npm install
doesn't update the package.json file, npm install *module name* --save
updates the json
package. Hope that helps.
Upvotes: 2