3

I have multiple project that uses node_modules which i didn't touched in month. If i can remove node_module only that can save my 5 to 8 GB storage.

I found Command line tool to delete folder with a specified name recursively in Windows But that shows delete file in specific folder like

D:\Project\Doing\prject1\
D:\Project\Complete\Project1\

FOR /d /r . %d IN (project1) DO @IF EXIST "%d" rd /s /q "%d"

But i don't want to search every directory to look for node_module instead i want to delete all the node_module folder from my PC (all the drive) how can i do that?

If I need the node_modules back I can simply run npm install so clearing space is good idea for me.

Ram Chandra Neupane
  • 1,826
  • 3
  • 19
  • 36

2 Answers2

3

I found the solution here that worked like a charm.

find . -name "node_modules" -exec rm -rf '{}' +

Ram Chandra Neupane
  • 1,826
  • 3
  • 19
  • 36
1

To list all your node_modules use this command in a command prom:

FOR /d /r . %d in (node_modules) DO @IF EXIST "%d" echo %d"

And for deleting you can do:

FOR /d /r . %d in (node_modules) DO @IF EXIST "%d" rm -rf "%d"

This will not work in powershell only cmd

Danielh
  • 173
  • 2
  • 8
  • I belive your command wild delete `node_module` inside `D` directory but want to delete `node_module` from all directory `( D C E)` – Ram Chandra Neupane Aug 01 '18 at 07:07
  • I was able to find all node_modules on my PC with this command, but looked like you found a solution that worked for you :) – Danielh Aug 01 '18 at 07:53