Assume I install project packages with npm install
that looks into package.json
for modules to be installed. After a while I see that I don't need some specific module and remove its dependency from package.json
. Then I remove some other modules from package.json
because they are not needed anymore and others are replaced with alternatives.
Now I want to clean node_modules
folder so that only modules listed in package.json
stay there and the rest must go, something like npm clean
. I know I can remove them manually but would like to have some nice ready to use sugar functionality for that.
Use following command instead of npm install
simple just run
in fact, you can delete any folder with this.
like rm -r AnyFolderWhichIsNotDeletableFromShiftDeleteOrDelete.
just open the gitbash move to root of the folder and run this command
Hope this will help.
Have you tried npm prune?
it should uninstall everything not listed in your package file
https://npmjs.org/doc/cli/npm-prune.html
First globally install rimraf
go to the path using cmd where your node_modules folder and apply below command
I think you're looking for
npm prune
See the docs: https://docs.npmjs.com/cli/prune