Cleaning Project Build Artifacts: node_modules, target, build, dist, .next
Last updated: 2026-04-13
Every project on your Mac leaves behind build output folders — node_modules in JavaScript and TypeScript projects, target in Rust and Java, build and dist in various frameworks, .next in Next.js apps, .nuxt in Nuxt.js apps, .cache in bundler tools, and Python virtual environment folders like venv and .venv. Since these folders are always regenerated by your build tool, deleting them is completely safe and can free tens of gigabytes.
Common build artifact folders
node_modules: JavaScript/TypeScript dependency trees (200 MB–1 GB per project). target: Rust compiled artifacts and Java/Gradle build output (1–5 GB per project). build/dist: output folders for React, Vue, Angular, webpack, Rollup, and other build tools. .next: Next.js build cache and compiled pages. .nuxt: Nuxt.js build output. .cache: Parcel, webpack, and other bundler caches. venv/.venv/env: Python virtual environments. __pycache__: Python bytecode cache folders.
How CodeCleaner's Project Scanner works
CodeCleaner's Project Scanner walks your filesystem looking for project root markers (package.json, Cargo.toml, build.gradle, Xcode project files, Makefile, etc.) and identifies all build artifact folders within each project. It ranks them by size with a "biggest offenders" list. Deletion is restricted to a whitelist of known safe folder names — only recognized build artifact directories can be removed.
Why build artifacts accumulate
Developers typically work across many projects over time. When you switch to a new project, the old project's build artifacts remain on disk. After months of development, you can have dozens of abandoned node_modules, target, and build folders consuming tens of gigabytes. These are fully regenerable by running the project's install or build command.
Scope find commands carefully
Limit find/rm to directories you own (for example ~/Developer or ~/Projects) so you do not traverse backups or network mounts. CodeCleaner's Project Scanner uses allowlists so only known artifact folder names are eligible for bulk removal.
Manual steps (Terminal)
You can do this manually with these commands, or use CodeCleaner to automate the process with a visual interface and safety checks. Each block shows a short label and the matching command.
Remove node_modules under Projects
find ~/Projects -name node_modules -type d -prune -exec rm -rf {} \;Remove Rust/Java target under Projects
find ~/Projects -name target -type d -prune -exec rm -rf {} \;Remove Next.js .next under Projects
find ~/Projects -name .next -type d -prune -exec rm -rf {} \;Remove dist folders under Projects
find ~/Projects -name dist -type d -prune -exec rm -rf {} \;Or use CodeCleaner
CodeCleaner automates all of this with a native macOS app. It auto-detects your installed tools, scans the relevant paths in parallel, shows per-item sizes, and lets you clean safely with one click. Free scan, no account required.