Automatically remove package.json dependencies when using npm uninstall

After npm init I can add the dependencies to my package.json package using this:

 npm install package --save 

And say, I want to uninstall package, and I do like this:

 npm uninstall package 

but I want my .json package to be updated as well, without having to manually go to the file and delete this line.

From npm docs it says:

It is strictly additive, so it does not remove the parameters from your package.json for no reason.

So, I just wanted to know if this is possible.

+81
Oct 16 '13 at 23:09
source share
3 answers

Use the same --save flag. If you installed the dependency with:

 $> npm install grunt-cli --save 

you can remove it, with package.json update using:

 $> npm uninstall grunt-cli --save 

The save flag tells npm to update package.json based on the operation you just did.

+146
Oct. 16 '13 at 23:22
source share
— -

In my case, --save did not clear the entry from package.json, the command suggested by ionic-check, I think if the removal fails with any errors, package.json will not be updated, and in this case you only have the option to manually change package.json, this is tiring, but I think this is the only way

UPDATE

when you delete a package that depends on another package that is active, in this case the removal may fail with errors / warnings, the safe method is the following dependency chart, which is not sure if there is any tool, a convenient tool for such operations warning messages are misleading, although "you must install peer dependencies .." does not make any sense when we remove the package

0
Nov 14 '18 at 8:04
source share

For node version 6.9.5 and window 7 final. Go to json path package and on cmd command line below line

npm remove dependency_name -save

-one
Apr 13 '17 at 9:22 on
source share



All Articles