惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
小众软件
小众软件
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
酷 壳 – CoolShell
酷 壳 – CoolShell
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - Franky
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
Hugging Face - Blog
Hugging Face - Blog
Jina AI
Jina AI
博客园 - 聂微东
S
SegmentFault 最新的问题
量子位
宝玉的分享
宝玉的分享
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园_首页

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I reclaimed 12GB from my SSD with one terminal command (a...
Mayne · 2026-06-18 · via DEV Community

Mayne

I've been a developer for over a decade, and if there's one thing I've learned, it's that our hard drives are basically landfills for build artifacts.

A few weeks ago, I was down to 2GB free on my main SSD. Not because I had tons of important files — but because I had years worth of node_modules folders, .next build caches, dist directories, and other junk scattered across dozens of old projects.

I tried reclaiming space manually. You know the drill — du -sh to find the culprits, then rm -rf them one by one. It works, but it's tedious. I tried npkill — it only handles node_modules. I tried wipe-modules — same limitation. I wanted something that could find everything at once and let me pick what to delete in one go.

So I built ZapDir.

What is ZapDir?

ZapDir is a terminal cleanup tool that scans your projects for heavy build artifacts and lets you delete them through a beautiful interactive interface. It's completely free, open-source under MIT, and runs on Windows, macOS, and Linux with Node.js 18+.

npm install -g zapdir
zapdir

Run that, and you'll see something like this:

⚡  ZapDir  —  Terminal Cleanup Tool

  🗑  Junk Found — Total recoverable:  1.47 GB

  ██████████  node_modules    /node_modules      245.23 MB
  ██████░░░░  .next           /.next               1.23 GB
  ██░░░░░░░░  dist            /dist                89.45 MB

  ✔  Delete 3 item(s) freeing 1.47 GB?  ·  Yes

  ✔  Freed 1.47 GB of disk space!

The colored size bars make it obvious what's eating the most space at a glance — red for anything over 500MB, yellow for over 100MB, and green for the rest.

What makes it different from npkill or wipe-modules?

There are other cleanup tools out there, but most of them only handle one pattern. Here's how ZapDir compares:

Feature ZapDir npkill wipe-modules
Patterns detected 13+ 1 (node_modules) 1 (node_modules)
Interactive TUI
Color-coded sizes
Dry-run preview
Async scanner
Cross-platform

ZapDir detects: node_modules, .next, .nuxt, .turbo, dist, build, .cache, coverage, out, target, .parcel-cache, __pycache__, and .DS_Store.

What it found on my machine

I ran ZapDir across my development machine and here's what turned up:

Location What was there Space recovered
~/Projects/legacy-app node_modules + .next 1.8 GB
~/Projects/side-project node_modules + build 640 MB
~/Projects/old-tutorial node_modules 420 MB
~/.cache Various caches 340 MB
Various Rust projects target/ directories 2.1 GB
Old Next.js projects .next caches 3.4 GB
Abandoned monorepos node_modules × 5 2.2 GB
Python projects __pycache__ + .cache 180 MB

Total reclaimed: roughly 12 GB

That's 12 GB I got back without touching a single file I actually needed. The biggest wins were old Next.js projects with massive .next caches (some over 1 GB each) and Rust projects where target/ directories had accumulated to over 2 GB combined.

Is it safe?

Short answer: yes, if you use --dry-run first.

zapdir --dry-run ~/Projects

This scans and shows you exactly what would be deleted without actually removing anything. The output shows every item with its size, path, and a visual bar so you know exactly what you're getting into.

When you're satisfied with the preview, run it without the flag. You'll be prompted to confirm before anything is deleted:

✔  Delete 3 item(s) freeing 1.47 GB?  ·  Yes / No

The scanner uses fs.promises.readdir with async parallel traversal for speed, and deletion is done with Promise.allSettled so a permission error on one file won't crash the entire operation — it just skips that file and continues. I've been using it for weeks and haven't lost a single file I needed.

How the scanning works

The core logic is surprisingly straightforward. It walks directories recursively using Node.js's built-in fs.promises, matches directory names against a list of known artifact patterns, calculates sizes using a streaming iterator (to avoid memory issues on huge folders), and presents everything in an interactive selection menu powered by @clack/prompts.

Hidden directories like .git are skipped by default for speed. The entire scan of my home directory — thousands of folders — completes in under 10 seconds.

A practical tip

Here's what I do now: once a month, I run:

zapdir --dry-run ~/Projects

This gives me a quick health check of how much junk has accumulated. When the number crosses 1 GB, I run it for real and reclaim the space. It's become part of my regular maintenance routine, right alongside brew update and npm outdated.

Give it a shot

If you're running low on disk space and have old projects lying around, try it:

npm install -g zapdir
zapdir

It takes five seconds to install and could free up gigabytes. The code is open source under MIT, so you can inspect exactly what it does before running it.

⭐ Star the repo on GitHub if you find it useful — it helps other developers discover it too.


ZapDir is MIT licensed and open source. Contributions, feature requests, and bug reports are welcome on GitHub.