node_modules Taking Up Space on Mac: Find and Delete Them All
The Silo Team · 5 min read · September 24, 2026
How Much Space Is node_modules Actually Using?
Run this to find out:
find ~ -name "node_modules" -type d -prune -exec du -sh {} \; 2>/dev/null | sort -hr
For most active developers, this reveals 10–40 GB spread across dozens of projects, many of which haven't been touched in months or years.
The Safe Approach: Only Delete Orphaned Directories
The key distinction: don't delete node_modules from projects you're actively working on. Target:
- Projects in directories with no git commits in 6+ months
- Cloned repos you were just exploring
- Tutorial projects
- Projects that have a
package.jsonbut whose repo is archived on GitHub
Using npkill for Interactive Cleanup
npx npkill
npkill shows an interactive list of all node_modules directories with sizes, letting you delete them one by one with the spacebar. It's safe and reversible (you can always run npm install to restore any deleted modules).
Clear Package Manager Caches Too
# npm cache
npm cache clean --force
du -sh ~/.npm/_cacache
# yarn v1 cache
yarn cache clean
# pnpm store
pnpm store prune
# Check pnpm store size
du -sh ~/.local/share/pnpm/store
MacPilot's Orphaned node_modules Scanner
MacPilot traverses your home directory and developer workspace, building a list of node_modules directories ranked by size. It cross-references each against its parent project's last Git commit date to identify stale candidates — giving you confidence about what's safe to delete.
Keep reading
How to Free Up Disk Space on Mac: The Developer's Complete Guide
From APFS clone-aware deduplication to DerivedData nukes and Docker.raw shrinking — the most complete storage reclaim guide for macOS engineers.
How to Kill a Process on a Port on Mac (localhost:3000, 5432, 8080)
The right way to find and kill whatever is listening on localhost:3000, 8080, or 5432 on macOS — using lsof, process tree resolution, and MacPilot.