I have a package.json
with all my devDependencies
.
My understanding was that if I remove a dependency, and run npm prune
, node will remove the module folder from node_modules
. This seems to be the easiest way to maintain my node_modules
folder.
From the docs:
npm prune
Remove extraneous packages
This command removes "extraneous" packages.
Extraneous packages are packages that are not listed on the parent package's dependencies list.
However, sometimes even after running npm prune
I still have the module folder in my node_modules
.
Why does this happen and what is the correct way to remove unused modules?
According to documentation
If the
--production
flag is specified, this command will remove the packages specified in yourdevDependencies
.
So, if you want to get rid of the module folder in node_modules
which is specified in devDependencies
, you shall execute
npm prune --production
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With