DiskSpace AI

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

ToolFolderCommand
npm~/.npm/_cacachenpm cache clean --force
pnpm~/Library/pnpm/storepnpm store prune
Yarn~/Library/Caches/Yarnyarn cache clean
Bun~/.bun/install/cachebun pm cache rm
pip~/Library/Caches/pippip cache purge
uv~/.cache/uvuv cache clean
Homebrew~/Library/Caches/Homebrewbrew cleanup -s
Gradle~/.gradle/cachesStop daemons (./gradlew --stop), then empty the folder
Playwright~/Library/Caches/ms-playwrightnpx 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 Beta

Folders in this guide

More guides