Back to Storage Guides
Developer Guide• 5 min read

How to Find & Delete node_modules Recursively on macOS

Every web developer has experienced it: months of prototyping, tutorial projects, and archived client repositories secretly consuming 50+ GB of SSD space in duplicate node_modules directories.

Why Do node_modules Folders Grow So Enormous?

In modern JavaScript and TypeScript development, even a small utility application pulls in thousands of transitive dependencies. Because npm, yarn, and older pnpm setups often duplicate packages per project, having 20–30 inactive repositories on your Mac can easily occupy 40 GB to 100 GB.

The Danger of Naive Terminal Scripts

Developers often attempt to purge dependencies using generic bash scripts:

Risky Terminal Command
find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
High Risk:Blind rm -rf commands permanently delete directories without using the macOS Trash. If you run this in the wrong parent folder or delete packages from an unpushed branch with uncommitted dependency patches, the work is unrecoverable.

The Safe Solution: DiskWarren Storage Intelligence

DiskWarren provides a dedicated developer scanner that indexes projects across your drive:

  1. Scans ~/Projects and custom developer directories in sub-second time.
  2. Checks Git commit recency and file access times to classify projects as Active versus Dormant.
  3. Presents exact sizes and item counts before any action is taken.
  4. Recycles chosen folders to the native macOS Trash so you can instantly click Put Back if ever needed.

Clean Stale node_modules Safely

Download DiskWarren for macOS • 100% Native & Private

Get Free App