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.
I have an
.npmrc
file that uses annpm
api built in-house to fetch packages. My issue was that I was not connected to my company'sVPN
.I had the same problem. When i installed some package, it was not shown on the package.json. So then I deleted the package.json file and ran npm init again. After that it was working and the packages I installed before was also there under dependencies.
The only way I was able to solve this was by using
npm install --save-dev moduleName
instead ofnpm install moduleName --save-dev
. Usingnpm install moduleName --save
works fine for me, though. Only when I use--save-dev
, I have to put it before themoduleName
. I hope this helps anyone.I ran into this recently, and figured out that for whatever reason it was Atom that was preventing the file from updating, even without the file being open.
I closed the editor, re-ran my npm install, opened the editor again and everything was as it should be.
I tried all the commands stated in above answers but got success on installing
npm-upgrade
package.npm i -g npm-upgrade
thennpm-upgrade
For me the issue was i copied the command from notepad++ it may have had special chars in there or it was the spaces, and it was not updating my package.json.
e.g. did not work;
npm install --save debug pug jwt-simple method-override mongoose
Make sure when you install, you clean up the command line, e.g. any spaces between each module, because there might be special chars in there as well depending on your encoding.
When i corrected it to this it worked.
npm install --save debug pug jwt-simple method-override mongoose
Also, please make sure the package.json isn't opened in an editor when you run the command, because not all editors handle this gracefully.