MacSonar.Our apps
← MacSonar Blog

How Much Space Do Developer Caches Really Take — and What Is Safe to Delete

node_modules, npm, Gradle, Cargo and pip caches can hold 20–80 GB on a dev Mac. What each one holds, what is safe to delete, and how to delete it.

A purple cabinet with five coloured drawers marked with a cache box, a terminal, code brackets, a gear and a folder, two drawers pulled out with small blocks spilling from them
An abstract illustration of developer caches: separate drawers for npm, Gradle, Cargo, pip and more, each quietly filling up.

Companion to Guide 1: How Much Space Xcode Really Takes and Guide 2: How Much Space iOS Simulators Really Take. Those cover Xcode and simulators; this guide covers the caches every other toolchain leaves behind.

The short answer

Every language you write in keeps a local copy of everything it has ever downloaded, and none of them clean up after themselves. A Node project keeps its dependencies in node_modules. npm keeps every tarball it has ever fetched in ~/.npm. Gradle keeps every dependency JAR in ~/.gradle/caches. Cargo keeps every crate in ~/.cargo/registry and every build in each project's target/ folder. pip keeps every wheel in ~/Library/Caches/pip.

On a Mac used for development for a year or more, these add up to 20–80 GB — and on a machine that has run several toolchains for two years, published guides report 50–150 GB recoverable without touching a single source file. Almost all of it is safe to delete: these are downloaded copies, not original work. The cost is time, not data — your next install or build re-downloads or rebuilds what it needs, and that takes longer than usual. The one thing to leave alone is a cache your active project is using right now, and anything you need while offline.

Where the space goes

WhatWhere it livesTypical size
node_modulesInside each project folder200 MB–2 GB per project; 10–50 GB across a dev Mac
npm cache~/.npm500 MB–8 GB; up to 15 GB after years
Gradle caches~/.gradle/caches5–15 GB; Android-heavy Macs 15–30 GB
Gradle wrapper~/.gradle/wrapper/dists500 MB–2 GB (80–200 MB per version)
Cargo registry~/.cargo/registry2–6 GB
Cargo target foldersInside each Rust project (target/)3–15 GB per project
pip cache~/Library/Caches/pip500 MB–5 GB; ML setups 10–20 GB

Sizes are ranges from published guides checked in November 2026. Your Mac will differ — the commands at the end of this guide show your exact numbers in seconds. On one Mac scanned in November 2026, the real numbers were: node_modules 2.8 GB across 7 folders, npm cache 812 MB, Gradle caches 476 MB, Gradle distributions 152 MB, and the Python tool uv at 339 MB.

A realistic recovery on a well-used dev Mac: 5–15 GB from stale node_modules folders alone, 3–8 GB from the npm cache, 5–15 GB from Gradle, 2–6 GB from the Cargo registry, 1–5 GB from pip — 20–50 GB in total, and more if you also clear per-project Rust target/ folders.

node_modules: one folder per project

Every Node project duplicates its entire dependency tree into a node_modules folder inside the project. A small CLI ships with 80–200 MB of dependencies. A typical React project runs 200–500 MB. A Next.js app sits between 500 MB and 1 GB. A monorepo with several workspaces runs 1–4 GB, and a Turborepo monorepo with five or more apps can reach 3–8 GB. An Electron app, which bundles a whole browser, runs 800 MB–2 GB.

The folder is per-project, so the total is the sum across every project you have ever cloned. A developer with four to eight active projects and several archived ones commonly recovers 10–50 GB by deleting the stale ones. One published audit of a 512 GB MacBook with two years of side projects found 73 GB across 92 node_modules folders — and 50 GB of that was in folders untouched for over six months.

Deleting a node_modules folder is safe if the project still has its lockfile (package-lock.json, yarn.lock or pnpm-lock.yaml). The lockfile is the recipe; node_modules is just the cooked meal. Run npm install (or yarn / pnpm install) and it comes back exactly as it was. The cost is the reinstall time: 30–90 seconds for a typical React or Next.js app, 3–7 minutes for a large monorepo.

find ~ -type d -name node_modules -prune | head -20  # find them
du -sh ~/projects/*/node_modules 2>/dev/null | sort -h  # size each one
rm -rf <project>/node_modules  # delete one (from outside the project)
cd <project> && npm install  # rebuild it when you need it again

Delete the folders for projects you have not opened in months, not the one you are working on today. Deleting an active project's node_modules does not destroy anything, but your next build fails until you reinstall — so do it when you can afford the reinstall time. And never delete a node_modules folder while npm install is running in that project.

npm cache: the download cache

npm keeps a content-addressable cache of every package tarball it has ever downloaded, at ~/.npm. Inside it, _cacache holds the compressed tarballs, _npx holds tools run once with npx, and _logs holds debug logs. The cache has no built-in expiry, so on a machine active for a year or more it routinely grows to 3–8 GB, and published guides report 5–15 GB on machines that have run for years. On the Mac scanned in November 2026 it measured 812 MB.

The cache is only a copy of downloads. Deleting it does not touch any project's node_modules, your installed packages, or your lockfiles. Your next npm install simply re-downloads what it needs, which is slower until the cache rebuilds. Use npm's own command rather than deleting the folder by hand, because npm keeps a checksum index inside the cache:

du -sh ~/.npm  # see how big it is
npm cache verify  # prune unreferenced data first
npm cache clean --force  # wipe the whole cache

Run npm cache verify first — it prunes unreferenced data and often reclaims space on its own. The --force flag is required for the full wipe.

If you use Yarn Classic, its cache lives at ~/Library/Caches/Yarn/v6 and is typically 1–6 GB; clear it with yarn cache clean. If you use pnpm, prefer pnpm store prune, which removes only packages no longer referenced by any local project, instead of wiping the whole store.

Gradle: the Java and Android cache

Gradle keeps almost everything under ~/.gradle. The caches/ subdirectory holds downloaded dependency JARs, transformed artifacts and build-cache entries — this is the largest part and the safest to delete. The wrapper/dists/ subdirectory holds one downloaded Gradle distribution per version your projects have ever used, at 80–200 MB each, so five to ten versions add up to 500 MB–2 GB.

On a project active for a year or two, ~/.gradle/caches routinely reaches 5–15 GB, and Android developers commonly see 15–30 GB because the Android build system downloads large support libraries and build tools. Published guides report developers recovering 10–40 GB from ~/.gradle/caches alone. On the Mac scanned in November 2026 it measured a modest 476 MB of caches and 152 MB of distributions.

Gradle 8 and later runs an automatic cache cleanup after 30 days, but it only prunes the oldest entries. A manual clear is still the way to reclaim the bulk of it:

du -sh ~/.gradle/caches ~/.gradle/wrapper  # see how big each part is
rm -rf ~/.gradle/caches  # wipe the caches

Deleting the caches does not touch your source code or your Gradle wrapper configuration. The next build re-downloads dependencies and re-resolves your project, so it takes longer — sometimes much longer on a large Android project. Do not clear Gradle caches right before you need to build offline, and do not delete ~/.gradle while a build is running.

Cargo: the Rust registry and target folders

Cargo keeps two kinds of data, and they are very different in size. The global registry at ~/.cargo/registry holds downloaded crate archives (registry/cache/, typically 500 MB–3 GB), unpacked crate source trees (registry/src/, 1–5 GB) and the crates.io index (registry/index/, 200 MB–600 MB). A developer active in Rust for a year typically sees 2–6 GB here. Git-sourced crates live separately in ~/.cargo/git/, usually 100 MB–2 GB.

The bigger number is per-project: each Rust project's target/ folder holds compiled artifacts, debug info and incremental build state, and a single mid-sized project can accumulate 3–15 GB there. Across several projects, 20–60 GB is common. That is why the total recoverable space for Rust is the largest of any toolchain in this guide — published guides report 10–25 GB from the registry and target/ folders combined, and 20–60 GB on machines with a long Rust history.

du -sh ~/.cargo/registry ~/.cargo/git  # the global registry and git caches
cargo clean  # clear this project's target/ (run inside the project)
cargo cache --autoclean  # prune the registry
rm -rf ~/.cargo/registry/cache ~/.cargo/registry/src  # wipe it by hand

cargo cache is a third-party tool — install it with cargo install cargo-cache before running --autoclean.

Do not delete ~/.cargo/bin/ — that holds tools you installed with cargo install, and deleting it removes the tools themselves, not a cache. And cargo clean only touches the project you run it in; to clear every project's target/ folder you have to visit each one, or use a tool that finds them for you.

pip: the Python wheel cache

pip keeps downloaded wheel files and source distributions so it can skip re-downloading packages you have already installed. On macOS the cache lives at ~/Library/Caches/pip, not the Linux default of ~/.cache/pip. (Run pip cache dir to confirm the exact path for your installation.)

A typical development machine accumulates 500 MB–5 GB here. A machine used for data science or machine learning accumulates more — a single PyTorch install adds about 3.7 GB, and published guides report 10–20 GB on heavy ML setups. The Python tool uv, a faster package manager, keeps its own cache at ~/.cache/uv; on the Mac scanned in November 2026 it measured 339 MB.

Everything in the pip cache is derived data: pip generated it from public sources and can regenerate it on demand. Clearing it does not touch your installed packages or your virtual environments:

du -sh ~/Library/Caches/pip  # see how big it is
pip cache purge  # wipe it

Do not clear the pip cache right before working offline — without it, pip cannot install anything until you are back on a network.

What not to delete

Check your own numbers

Paste these one at a time in Terminal. Each prints the size of one thing:

find ~ -type d -name node_modules -prune | wc -l  # count them
du -sh ~/.npm  # npm cache
du -sh ~/.gradle/caches ~/.gradle/wrapper  # Gradle caches
du -sh ~/.cargo/registry ~/.cargo/git  # Cargo registry and git caches
du -sh ~/Library/Caches/pip  # pip cache

The honest bit

Deleting developer caches does not make your Mac faster. It makes room. The next install re-downloads packages, the next build recompiles them, and both take longer than they did with a warm cache. That is the trade, and it is usually a good one: a few minutes of slower installs, someday, for tens of gigabytes back today.

The caches that matter most are the ones you have not touched in months — the node_modules folder of a project you finished last spring, the Gradle cache of an Android app you no longer maintain, the Cargo registry of crates you tried once. Those are not speeding anything up. They are just sitting there, holding disk space for work you have already finished.

Sources

Keep reading

← More from the MacSonar Blog