Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't `npm prune` remove folders from node_modules?

Tags:

node.js

npm

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?

like image 220
elanh Avatar asked Nov 20 '13 10:11

elanh


1 Answers

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

like image 179
Andrei Karpushonak Avatar answered Sep 18 '22 14:09

Andrei Karpushonak