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

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.


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.


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