1

I'm doing a HDD upgrade, and while trying to backup my NodeJS projects i realize that all node_modules subfolders have over 1 milion files.

So i'm looking for a way to remove all the node_modules subfolders and all their contents.

The projects are located in :

C:/Node/App1/node_modules/.. C:/Node/App2/node_modules/.. C:/Node/App3/node_modules/.. etc.. 

My OS is Windows 10, but i can try either Windows or Linux commands because i'm using cmder, and it accepts both types of commands.

2
  • you can try rm -rf <folder name> Commented Jan 10, 2017 at 13:18
  • That works if i'm in the correct folder. But i need to search for all node_modules folders first and wipe out everything inside them. Commented Jan 10, 2017 at 13:20

2 Answers 2

7

For Linux:

cd Node find . -maxdepth 2 -name node_modules -type d -exec rm -rf {} + 
Sign up to request clarification or add additional context in comments.

Comments

6

I tested this command in various situations and it seems to work fine.

for /d /r . %d in (node_modules) do @if exist "%d" rd /s/q "%d" 

I'm not sure how it works, it's an adapted solution from Here, if you need more details.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.