JavaScript's node_modules folder is notorious for its size. A typical React project can easily have 200+ MB of dependencies, and that's for a relatively simple app.
If you're working on multiple projects, those folders add up fast. Here's how to clean them safely.
The Manual Approach
You could manually find and delete old node_modules folders:
# Find all node_modules folders
find ~ -name "node_modules" -type d -prune
# Delete them (be careful!)
find ~ -name "node_modules" -type d -prune -exec rm -rf {} +
Warning: This approach is risky. You might delete dependencies for a project you're actively working on.
The Smart Approach
Before deleting any node_modules folder, you should ask:
- When was this project last modified? If it was 6 months ago, it's probably safe to clean.
- Is this a git repository? If so, are there uncommitted changes?
- Can you easily reinstall? Is there a
package-lock.jsonoryarn.lock?
What Cluttered Does Differently
Cluttered automates this entire process:
- Scans your entire drive for Node.js projects
- Checks git status to ensure no uncommitted work
- Analyzes activity using file modification times
- Shows clear indicators - green (safe), yellow (caution), red (active)
- Deletes to Trash so you can recover if needed
Real-World Results
A typical developer machine has:
- 10-20 Node.js projects
- Average
node_modulessize: 300 MB - Total recoverable: 3-6 GB (or more)
And the best part? Running npm install in any project will restore it instantly.
Tips for Keeping Things Clean
- Use a single global cache: npm and yarn both support global caching
- Delete old projects: If you haven't touched it in a year, archive and delete it
- Use Cluttered regularly: Set up automatic cleaning for inactive projects
Conclusion
You don't need to let node_modules folders consume your disk. With the right approach, you can keep your machine clean while staying productive.
Download Cluttered and reclaim your disk space in minutes.