Why doesn't `npm prune` remove folders from node_modules?
node.js, npm
Solution
According to documentation
If the `--production` flag is specified, this command will remove the packages specified in your `devDependencies`.
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`
Problem
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?