Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm install packagename --save-dev not updating package.json

Are there simple or subtle reasons that package.json would not update after running a --save-dev? This is my command:

npm install modulename --save-dev

Run from the root of the project. The command succeeds, the new module shows up in the node_modules directory as expected. Help would be appreciated. I am using npm v 1.4.28

The entirety of my current package.json is:

{     "name": "FooWeb",     "version": "1.0.0",     "description": "Foo Web",     "devDependencies": {         "gulp": "3.8.11",         "gulp-jshint": "1.9.2",         "gulp-concat": "2.5.2",         "gulp-sass": "1.3.3",         "gulp-sourcemaps": "1.4.0",         "gulp-watch": "4.1.1"     } } 

I do get warnings on install of a package that I have no repository field or README, but I think that is not related.

like image 519
Brian Muenzenmeyer Avatar asked May 06 '15 14:05

Brian Muenzenmeyer


People also ask

Does npm update change package json?

As of [email protected] , the npm update will change package. json to save the new version as the minimum required dependency. To get the old behavior, use npm update --no-save .

Does npm update install Dev dependencies?

Yes and no! If the packages have already been installed into the node_modules folder, then npm install won't update any packages. If the packages haven't been installed and a package-lock. json file exists, then npm install will install the exact dependency versions specified in package-lock.

How install Dev dependencies npm from package json?

To add dependencies and devDependencies to a package. json file from the command line, you can install them in the root directory of your package using the --save-prod flag for dependencies (the default behavior of npm install ) or the --save-dev flag for devDependencies.


2 Answers

I had this problem as well, and it was driving me crazy.

What finally fixed it was running npm init. This added a bunch of stuff to my package.json, but afterwards --save-dev worked as expected. Even after I removed all the new stuff added by npm init, --save-dev still worked.

like image 121
hook Avatar answered Sep 22 '22 19:09

hook


I had the -g flag there, when I removed it, it worked as expected ...

like image 40
Mustafah Avatar answered Sep 19 '22 19:09

Mustafah