How to clear npm, pnpm, pip, uv and Homebrew caches on Mac
In short
Package managers keep a copy of everything they ever downloaded. It's safe to clean: they download again what they need. Use each tool's own command when there is one (it knows what's still in use), and close the tool first.
Where they are and how to clean them
| Tool | Folder | Command |
|---|---|---|
| npm | ~/.npm/_cacache | npm cache clean --force |
| pnpm | ~/Library/pnpm/store | pnpm store prune |
| Yarn | ~/Library/Caches/Yarn | yarn cache clean |
| Bun | ~/.bun/install/cache | bun pm cache rm |
| pip | ~/Library/Caches/pip | pip cache purge |
| uv | ~/.cache/uv | uv cache clean |
| Homebrew | ~/Library/Caches/Homebrew | brew cleanup -s |
| Gradle | ~/.gradle/caches | Stop daemons (./gradlew --stop), then empty the folder |
| Playwright | ~/Library/Caches/ms-playwright | npx playwright uninstall --all |
Why the tool's command is better
Deleting the folder works, but the tool's own command knows what's still referenced. pnpm store prune, for example, only removes packages no project uses, while deleting the store makes every project download everything again.
node_modules from old projects
Each project has its own node_modules, often 200 MB to 1 GB. For projects you haven't touched in months, deleting it is safe: npm install (or pnpm, yarn) brings it back from the lockfile. Leave the ones of projects you're working on.
Python virtual environments
A .venv folder is the same story: it can be recreated from requirements.txt or pyproject.toml. Old ones from finished projects can go.
DiskSpace AI does this for you
It analyzes your Mac in minutes, tells you what each folder is and only selects what recreates itself. Your files are kept 7 days in case you change your mind. Free during the beta.
Download the BetaFolders in this guide
- npm cache
~/.npm/_cacacheRecreates itself - pnpm store
~/Library/pnpm/storeRecreates itself - Yarn cache
~/Library/Caches/YarnRecreates itself - Bun cache
~/.bun/install/cacheRecreates itself - pip cache
~/Library/Caches/pipRecreates itself - uv cache (Python)
~/.cache/uvRecreates itself - Homebrew cache
~/Library/Caches/HomebrewRecreates itself - Gradle cache
~/.gradle/cachesRecreates itself - Playwright browsers
~/Library/Caches/ms-playwrightRecreates itself
More guides
- Not enough space to update macOS? How to make room safely
- What is “System Data” on a Mac, and why is it so big?
- How to free up space on your Mac without deleting anything important
- How to find and delete duplicate photos on Mac
- Docker taking up too much space on Mac? How to shrink Docker.raw
- Xcode taking up space? What you can delete (and what you can't)
- How to find large files on Mac (including hidden ones)
- What is purgeable space on Mac, and how to free it
- DaisyDisk alternative: DiskSpace AI vs DaisyDisk
- CleanMyMac alternative without a subscription
- The best disk space analyzers for Mac in 2026