# How to Clean node_modules, Rust Cargo, Python uv/Conda & Homebrew on Mac

> Full-stack Mac developers accumulate tens of gigabytes across two layers: per-project build folders (node_modules, Rust target/, Python .venv/, Next.js .next/, Pods/, Flutter build/) and global package stores (Homebrew downloads & old Cellar versions, ~/.cargo/registry, ~/.rustup/toolchains, uv/pip/Conda caches, pnpm/Yarn/npm stores, and old Playwright/Cypress browsers). Almost all regenerate or re-download cleanly.

- **Canonical URL**: https://cruft.app/guides/clean-node-modules-rust-python-homebrew-mac
- **Category**: Cross-Platform & Packages
- **Typical Reclaimable Space**: 15–100+ GB
- **Last Updated**: 2026-12-04

## Quick Facts

- **Typical reclaimable space**: 15–100+ GB
- **Safe project folders**: node_modules, target, .venv, build, .next, .turbo, Pods, .dart_tool, .build
- **Safe global caches**: Homebrew downloads, uv/pip/Poetry/Ruff, Cargo registry, Playwright old revisions
- **Protect before deleting**: Default Rustup toolchain, active Conda envs, folders named build/target without a manifest

## Exact macOS Paths & Safety Reference

| Location | macOS Path | Typical Size | Safety | Rebuild / Effect |
| --- | --- | --- | --- | --- |
| Stale Project Build Folders | `node_modules, target, .venv, build, .next, Pods, .dart_tool, .build` | 5–60 GB | Re-download | Restored via npm/pnpm install, cargo build, uv sync, flutter pub get, or pod install. |
| npm, pnpm, Yarn, Bun & Node Managers | `~/.npm, ~/Library/pnpm/store, ~/Library/Caches/Yarn, ~/.bun, ~/.nvm` | 2–20 GB | Re-download | Package caches re-download on install; older Node versions can be reinstalled via nvm/fnm/mise. |
| Homebrew Cache & Old Cellar Versions | `~/Library/Caches/Homebrew & /opt/homebrew/Cellar` | 2–15 GB | Re-download | Equivalent to brew cleanup; never touches active linked formula versions. |
| Rust Cargo Registry & Rustup Toolchains | `~/.cargo/{registry,git} & ~/.rustup/toolchains` | 3–20 GB | Re-download | Crates re-download on build; keep your default and project-pinned Rustup toolchains. |
| Python uv, pip, Poetry & Conda | `~/Library/Caches/{uv,pip,pypoetry}, ~/.local/share/uv/python, ~/*conda*/{pkgs,envs}` | 3–25 GB | Re-download | Wheel caches and Conda pkgs re-download safely; review Conda envs before removing. |
| Playwright, Puppeteer, Cypress & Electron | `~/Library/Caches/{ms-playwright,Cypress,electron} & ~/.cache/puppeteer` | 2–12 GB | Re-download | Test runners download fresh browser revisions on upgrade and leave old revisions behind. |
| Flutter SDKs, Dart Pub & React Native | `*/flutter/bin/cache, ~/.pub-cache, ~/.dartServer, $TMPDIR/metro-*` | 3–18 GB | Re-download | Flutter engine caches and Metro caches rebuild automatically on next run. |

## 1. Clean stale per-project build folders without touching source code

A single Rust workspace target/ directory easily reaches 5–15 GB, and a dozen inactive JavaScript repos each carry 400 MB–1.5 GB of node_modules plus .next or .turbo caches. The key rule for safety is manifest verification: only treat a folder named build, target, or .venv as generated output when a matching project file (Cargo.toml, pom.xml, package.json, pubspec.yaml, pyproject.toml, Package.swift, or build.gradle) sits directly next to it.

**Find large node_modules & Rust target folders in ~/Developer**

```sh
find ~/Developer -maxdepth 4 -type d \( -name node_modules -o -name target -o -name .venv \) -prune -exec du -sh {} + 2>/dev/null | sort -hr
```

## 2. Run targeted global cache cleanups for Brew, Cargo, and Python

Package managers optimize for offline reinstalls by keeping downloaded tarballs, wheels, bottles, and older toolchain revisions forever unless told to prune them:

**Safe CLI cleanup commands across Homebrew, uv, pip, Conda & pnpm**

```sh
brew cleanup --prune=all
uv cache prune
pip cache purge
conda clean --all
pnpm store prune
rustup toolchain list
```

> Note: Check rustup toolchain list before running rustup toolchain uninstall — never remove the active default toolchain.

## 3. Don't forget Playwright, Puppeteer, Cypress & Flutter engine caches

End-to-end test frameworks download full Chromium, Firefox, and WebKit binaries (~300–500 MB per browser) on every version bump and rarely delete old revisions from ~/Library/Caches/ms-playwright, ~/.cache/puppeteer, or ~/Library/Caches/Cypress.

Similarly, every Flutter SDK stores ~3 GB of engine binaries in bin/cache, and version managers like FVM, asdf, or mise can leave multiple 3+ GB SDK copies sitting side by side.

## How Cruft Automates This Safely

- Verifies adjacent project manifests (package.json, Cargo.toml, pyproject.toml, pubspec.yaml, Podfile, Package.swift) before listing any build folder — so a source folder named build or target is never touched.
- Reads ~/.rustup/settings.toml to lock your default Rust toolchain and protect pinned directory overrides, while keeping active Homebrew opt/ links untouched.
- Finds outdated Playwright, Puppeteer, Cypress, Node manager, Flutter SDK, uv, pip, Poetry, and Conda caches in one unified scan.

Download Cruft free to scan (https://updates.cruft.app/Cruft.dmg) or buy a lifetime 3-Mac license for €15 once (https://license.cruft.app/buy).

## Frequently Asked Questions

### Is it safe to delete Rust Cargo target/ folders and ~/.cargo/registry?

Yes. Both target/ (compiled build artifacts next to Cargo.toml) and ~/.cargo/registry/{cache,src} regenerate on the next cargo build. Only your first rebuild will take longer while crates recompile.

### How much space does uv cache use on macOS, and is it safe to clear?

uv caches wheels and unpacked archives in ~/Library/Caches/uv (or $UV_CACHE_DIR) and can easily grow to 5–15 GB across Python projects. Clearing it is completely safe; uv re-downloads wheels on the next uv sync.

### Will deleting pnpm's global store break existing node_modules?

pnpm hard-links files from its store into each project's node_modules. Deleting the store directory unlinks the store's references while keeping existing project hard-links valid on APFS, though running pnpm store prune or deleting unused project node_modules first is cleaner.
