Delete ALL node_modules folders on My computer

image-1

List all node_modules

you can cd into where most of your projects are.

  • Mac / Linux:
$ cd project
$ find . -name "node_modules" -type d -prune -print | xargs du -chs

...
$ find . -name "node_modules" -type d -prune -print | xargs du -chs
251M    ./jaedsadadotme/jaedsadadotme-blog/node_modules
102M    ./jaedsadadotme/jaedsada.me/node_modules
353M    total
  • Window
$ FOR /d /r . %d in (node_modules) DO @IF EXIST "%d" echo %d"

Delete all node_modules

  • Mac / Linux:
$ cd project
$ find . -name 'node_modules' -type d -prune -print -exec rm -rf '{}' \;
  • Windows:
$ cd project
$ FOR /d /r . %d in (node_modules) DO @IF EXIST "%d" rm -rf "%d"

Ref :

How to delete ALL node_modules folders on your machine and free up HD space!

October 27, 2020