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.
This happened to me on Intellij
For anyone else having this issue, did you copy your project from an existing project?
If so, close Intellij and delete the
.idea
folder. (You can deletenode_modules
too get a fresh start)Open the project again and this will be resolved.
There was a syntax error in my package.json that was causing this for me!
I had the -g flag there, when I removed it, it worked as expected ...
navigate to JSON file -> right click properties -> remove "read only" flag.
This can occur in VSCode (or probably other editors) if you have an unsaved
package.json
open.The file was actually being updated but not reloaded in the IDE. I think maybe the default is to reload only if the file is unedited? Or maybe I clicked something to ignore warnings.
With the accepted answer still my problem not resolve, then I try to change syntax position Previously I am using the following command to install the module to devDependencies
Then I toggle the position of moduleName and --save-dev and the moduleName successfully added in the package.json file
Then the the package.json file updated with the moduleName.