DEV Community

Cover image for I Nuked All My node_modules and Saved ~10GB
Luka Vukanović
Luka Vukanović

Posted on

I Nuked All My node_modules and Saved ~10GB

The Problem: When Backups Take Forever

I was backing up my entire Documents folder to an external SSD. Simple task, right? Wrong.

2 hours later, I was still watching the progress bar crawl. Not because of large video files or databases — but because of node_modules. Those tiny JavaScript files, tens of thousands of them per project, were destroying my backup speed.

The issue wasn't even the disk space (though yeah, 10GB is 10GB). It was the sheer number of files. Each node_modules folder has thousands of tiny dependencies, and copying thousands of small files is painfully slow compared to a few large ones.

I had dozens of old projects in my Documents folder. Projects I hadn't touched in months. Each one still carrying around its own bloated node_modules like dead weight.

The Breaking Point

I realized: I don't need these. If I ever work on these projects again, I can just run npm install. Why am I backing up gigabytes of reconstructable dependencies?

So I did what any developer would do — I looked for a tool to nuke them all at once.
I googled around, but nothing quite fit in what I need:

  • Safe by default (skip recent projects)
  • Fast scanning
  • Cross-platform
  • Simple CLI
  • No accidentally deleting system tools like .nvm or .npm

So I spent a weekend building nukenm (nuke node_modules - Honestly, I really like the name).

The Tool: nukenm

Here's what it looks like in action:
Basic scan to see what you're working with:

Basic scan

Quiet mode for minimal output:

Quiet mode

Full help screen showing all options:

Help

Aggressive cleanup when you're sure:

Aggressive cleanup

Safety First

The tool is safe by default:

  • Only targets folders not modified in the last 14 days (configurable)
  • Skips hidden directories (protects .nvm, .npm, .cache)
  • Dry run first — always shows what will be deleted
  • Confirmation prompt before actual deletion
  • Respects filesystem boundaries — won't cross into external drives
# Safe preview
nukenm scan ~/Documents

# Delete old projects (30+ days untouched)
nukenm nuke ~/Documents --days 30

# Nuclear option (careful!)
nukenm nuke ~/Documents --days 0 -y
Enter fullscreen mode Exit fullscreen mode

The Results
After running it on my Documents folder:

  • Deleted: 345 node_modules folders
  • Freed: 8.7 GB of disk space
  • Backup time: 2 hours → 15 minutes

The real win wasn't the disk space — it was the speed. Backing up my projects is now actually feasible.

Try It Yourself
The tool is open source and available now:

# Install (if you have Go)
go install github.com/vukan322/nuke-node_modules@latest

# Or download the binary from GitHub #
https://github.com/vukan322/nuke-node_modules/releases
Enter fullscreen mode Exit fullscreen mode

Basic usage:

# Preview what will be deleted
nukenm scan ~/Documents

# Actually delete (with confirmation)
nukenm nuke ~/Documents

# Quiet mode for scripts
nukenm scan ~/Documents --quiet

# See all options
nukenm --help
Enter fullscreen mode Exit fullscreen mode

What's Next?
I'm planning to add:

  • Parallel deletion with goroutines (faster on large scans)
  • Package manager installation (brew, apt, scoop)
  • Scheduled cleanup (cron/Task Scheduler integration)
  • Config file for custom rules

If you have ideas or want to contribute, the repo is nuke-node_modules.

Top comments (0)