Clear npm, pip, Homebrew & node_modules caches and free up disk space
Package managers trade disk for speed. Every install, every project, every version leaves something behind — and it adds up fast. On a working developer machine, npm, pip, Homebrew, and stray node_modules folders routinely account for 10–80 GB that nothing prompts you to clean. Here's where it hides, and the safe way to clear it on macOS and Windows.
Where each cache lives and why it bloats
These tools cache downloaded packages so they don't have to re-fetch them next time. The caches are meant to be disposable — but nothing rotates them out, so they grow unbounded.
npm
npm keeps a global content-addressable cache of every package tarball it has ever downloaded. It never shrinks on its own. Default locations:
- macOS / Linux:
~/.npm - Windows:
%LocalAppData%\npm-cache(older setups:%AppData%\npm-cache)
pip
pip caches downloaded and built wheels so reinstalls are instant. Across many virtualenvs and Python versions, the wheel cache balloons. Default locations:
- macOS:
~/Library/Caches/pip - Linux:
~/.cache/pip - Windows:
%LocalAppData%\pip\Cache
Homebrew
Homebrew (macOS) keeps old download tarballs and outdated versions of every formula and cask you've installed or upgraded. It's set to remove downloads older than 120 days automatically, but old installed versions and recent downloads linger. The cache lives at ~/Library/Caches/Homebrew.
node_modules
This is the big one. Every JavaScript project you've ever cloned has its own node_modules folder — often hundreds of megabytes each. The ones in projects you haven't touched in months are pure dead weight, sitting on disk long after you stopped working on them.
Yarn & pnpm
Yarn and pnpm keep their own global stores (~/.yarn / Yarn Berry's cache, and pnpm's content-addressable store), which grow the same way npm's does.
macOS: inspect first, then clear
Before deleting anything, look at how big each cache actually is. That tells you where the space really went.
du -sh ~/.npm ~/Library/Caches/pip ~/Library/Caches/Homebrew 2>/dev/nullnpm
Clear the npm cache. The modern npm cache is self-healing, so the official way to force-clear it is:
npm cache clean --forceAfterward you can confirm the cache is intact and consistent with:
npm cache verifynpm cache verify also garbage-collects unused entries, so it's a gentle option on its own if you'd rather not force-clean.
pip
Check what's there, then purge every cached wheel:
pip cache info
pip cache purge(Use pip3 instead of pip if that's how Python is installed on your machine.)
Homebrew
Start with a dry run so you can see exactly what would be removed — nothing is deleted yet:
brew cleanup -nThen run it for real to remove stale downloads and outdated installed versions:
brew cleanupTo go further and scrub even the latest cached downloads (installed formulae stay intact), add -s, or clear cache files older than a cutoff:
brew cleanup -s
brew cleanup --prune=allYarn & pnpm
yarn cache clean
pnpm store prunepnpm store prune is especially safe: it only removes packages no project currently references.
Stale node_modules
Find the biggest offenders under your projects folder:
find ~/Projects -name node_modules -type d -prune -exec du -sh {} +Delete a specific one you're done with (moves nothing to Trash — see the warning below):
rm -rf ~/Projects/old-app/node_modulesYou can always restore it later with npm install (or yarn / pnpm install) inside that project — the folder is fully regenerated from your lockfile.
Heads up: rm -rf deletes immediately and permanently — there is no Trash and no undo. Double-check the path (especially the project name) before you hit enter, and never run it against a path you're unsure of.
Windows: inspect first, then clear
The package-manager commands are identical on Windows; only the cache paths and the delete command differ. Run these in PowerShell.
npm
npm cache clean --force
npm cache verifyTo see the size of the npm cache folder:
Get-ChildItem "$env:LocalAppData\npm-cache" -Recurse | Measure-Object -Property Length -Sumpip
pip cache info
pip cache purgepip's Windows cache lives at %LocalAppData%\pip\Cache.
node_modules
Homebrew doesn't exist on Windows, but stale node_modules folders absolutely do. To remove one you're finished with, in PowerShell:
Remove-Item -Recurse -Force "C:\dev\old-app\node_modules"Heads up: Remove-Item -Recurse -Force bypasses the Recycle Bin — deleted files do not go anywhere recoverable. Confirm the path before running it, and re-run npm install in the project whenever you need the folder back.
What's safe vs. what's risky
Safe to clear anytime:
- The npm, pip, Homebrew, Yarn, and pnpm caches — these are pure download caches. Clearing them only means the next install re-downloads, so it's slower once, never broken.
- node_modules in projects you're not actively working on — always regenerable from the lockfile with a single install command.
Be careful with:
- node_modules in a project with no lockfile (no
package-lock.json,yarn.lock, orpnpm-lock.yaml). Without a lockfile, a reinstall can pull different versions. Commit or generate a lockfile first. - Anything under a cache path you didn't verify. Deleting the right folder is safe; deleting the wrong one with
rm -rf/Remove-Item -Forceis not. - Global tools installed by these managers — clearing a cache never touches installed packages, but a stray
rm -rfon the wrong directory could. Prefer the built-incachesubcommands over manual deletion.
Or clear all of it, safely, in one pass
Vaulith finds your npm, pip, Homebrew, Yarn, and pnpm caches — plus Xcode, simulator, and browser caches and the rest of the hidden dev-cache iceberg (on Windows: npm, pip, Yarn, and NuGet caches, temp files, and crash dumps too) — safety-verifies each location before it touches anything, shows you exactly what it found and how much it'll free, and moves everything to the Trash so you can review and undo. No rm -rf, no guessing at paths. (node_modules folders: use the commands above — safe and quick by hand.) It runs 100% on your device; your files never leave your machine.
Frequently asked questions
Will clearing these caches break my projects?
No. Caches only hold downloaded copies of packages — clearing them just means the next install re-downloads what it needs. Your source code, lockfiles, and installed global tools are untouched. The only cost is a slightly slower first install afterward.
How much space will I actually get back?
It depends heavily on how long you've been developing on the machine and how many projects you keep around. Package-manager caches alone commonly hold a few gigabytes; add up stale node_modules folders and developers often reclaim 10–80 GB in total. Individual results vary — run the inspect commands above to see your own numbers first.
Do I need to reinstall anything after cleaning?
Only if you deleted a node_modules folder for a project you then go back to — run npm install (or yarn / pnpm install) in that project and it rebuilds from the lockfile. Clearing the caches themselves requires no action; they simply repopulate as you install packages.