DEV Community

Bradley Nash
Bradley Nash

Posted on

How npm, pnpm, and yarn Ate 40GB of My 256GB SSD

Last week my MacBook started complaining: "Your disk is almost full."

I had 8GB free. On a 256GB machine. I hadn't downloaded any movies or photos. What was going on?

The Investigation

I started hunting. First suspect: node_modules.

find ~ -name "node_modules" -type d -exec du -sh {} \; 2>/dev/null
Enter fullscreen mode Exit fullscreen mode

The results made me want to cry:

~/projects/2022-client-work/node_modules              1.2GB
~/projects/abandoned-react-app/node_modules          890MB
~/projects/experiment-three-js/node_modules          750MB
~/projects/old-work-project/node_modules             1.8GB
~/projects/that-one-tutorial/node_modules            420MB
# ...20 more entries
Enter fullscreen mode Exit fullscreen mode

25GB of node_modules from projects I hadn't touched in months. Some were from 2022.

Then I checked the package manager caches:

npm cache verify    # 3.2GB
pnpm store prune    # Would free 5GB
yarn cache clean    # 2.1GB
Enter fullscreen mode Exit fullscreen mode

Another 10GB just sitting in package manager caches.

In total: 40GB of JavaScript build artifacts and caches. On a 256GB SSD, that's 15% of my entire disk — gone to a dependency graveyard.

The Three Package Managers Problem

If you work with JavaScript/TypeScript, you know this pain. You try npm. Then pnpm for speed. Then yarn for work. Each one maintains its own cache in a different location:

  • ~/.npm — npm's cache
  • ~/Library/pnpm — pnpm's store
  • ~/Library/Caches/Yarn — yarn's cache

Plus every project has its own node_modules. You npm install once, build, deploy... and that folder sits there forever. Multiply by 20+ projects over 3 years.

I found a React project from 2022 with 1.8GB of node_modules. I had run npm install exactly once, built the project, and never touched it again. That 1.8GB sat on my SSD for 3 years.

Xcode Wasn't Innocent Either

While I was at it, I checked Xcode's cache:

du -sh ~/Library/Developer/Xcode/DerivedData
# 47GB
Enter fullscreen mode Exit fullscreen mode

So my actual breakdown was:

  • node_modules: 25GB
  • npm/pnpm/yarn caches: 10GB
  • Xcode DerivedData: 47GB
  • Docker images: 8GB
  • Rust/Python/Go build artifacts: 5GB

95GB of dev cache on a 256GB machine. My actual code? Under 3GB.

The Manual Cleanup (Don't Do This)

I spent a Saturday manually cleaning:

# Delete old node_modules... carefully
rm -rf ~/projects/2022-*/node_modules

# Clean package manager caches
npm cache clean --force
pnpm store prune
yarn cache clean

# Wait, where does pnpm store things again?
# And did I just break something?
Enter fullscreen mode Exit fullscreen mode

It took 3 hours. I was paranoid about deleting the wrong thing. And I knew I'd have to do it again in 6 months.

Building DevCleaner

I wanted a tool that would:

  1. Find everything automatically — node_modules, npm cache, pnpm store, yarn cache, and 40+ other dev tools
  2. Show me before deleting — no surprises, no "oops I deleted the wrong folder"
  3. Move to Trash first — so I can verify nothing broke before emptying
  4. Be fast — scan my entire disk in seconds, not hours

So I built it. In Nim, because I wanted to learn something new and ship something fast.

The Results

First scan: 63GB of cleanable cache.

I reviewed the list — all old projects, all safe to delete. Clicked "Clean All", everything moved to Trash. Verified my current projects still worked. Emptied Trash.

63GB back. My 256GB MacBook finally had breathing room again.

See it in action:

Try It

If you're a JavaScript/TypeScript developer on macOS, I guarantee you have gigabytes of node_modules folders from abandoned projects. That npm package cache? Still growing.

DevCleaner finds and cleans:

  • ✅ node_modules (npm/yarn/pnpm)
  • ✅ npm cache, pnpm store, yarn cache
  • ✅ 40+ other dev tools (Xcode, Docker, Rust, Python, etc.)

$4.99 while I gather feedback: https://bradleynash.gumroad.com/l/devcleaner

One-time purchase. No subscriptions. Lifetime updates.


How much dev cache is hiding on your machine? Run this and find your node_modules graveyard:

find ~ -name "node_modules" -type d -exec du -sh {} \; 2>/dev/null | sort -hr | head -20
Enter fullscreen mode Exit fullscreen mode

What's your biggest offender?

Top comments (0)