Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find all node_modules directories [duplicate]

I am a web developer. I checkout many OSS projects and build them. Node modules are notorious in creating too many small files. I am running out of free iNodes because of that. I want an easy way (in linux) to lookup for all node_modules and delete unwanted ones. I am using the below command to list all node_modules directory and then delete them manually.

find ~/projects -name node_modules -prune

Is there a first-class utility that provides better way to manage node_modules?

like image 517
Varunkumar Nagarajan Avatar asked Sep 04 '17 13:09

Varunkumar Nagarajan


People also ask

How do I find the modules installed on a node?

If you set the NODE_PATH environment variable to this path, the modules can be found by node. Non-global libraries are installed the node_modules sub folder in the folder you are currently in.

How do I know if a library is installed on node?

If you set the NODE_PATH environment variable to this path, the modules can be found by node. Non-global libraries are installed the node_modules sub folder in the folder you are currently in. You can run npm list to see the installed non-global libraries for your current location.

Where are non-global libraries installed in node?

Non-global libraries are installed the node_modules sub folder in the folder you are currently in. You can run npm list to see the installed non-global libraries for your current location. Show activity on this post.

How much space does a node module take up?

A single node_modules folder can take up anywhere from 200+ megabytes of space (sometimes 1GB+ !). Now take a look at your github/ folder, or wherever else you're storing the majority of your projects, and you can start to see where some of your free hard-drive space has gone!


Video Answer


1 Answers

Just use this: find . -name "node_modules" -prune -exec rm -rf '{}' +

like image 79
BILL Avatar answered Oct 15 '22 17:10

BILL