Bytewell
  • Features
  • Pricing
  • Menu
    • Features
    • Pricing
  • EN
    • English
    • Deutsch
    • Español
    • 日本語
    • Türkçe
    • 简体中文
    • 繁體中文
  • Download
Bytewell›Guides

How to find and delete old node_modules folders and package caches on a Mac

Updated November 1, 2026

Every JavaScript project carries its own node_modules, often 200 MB to 1 GB, and package managers keep a second copy of everything in their caches. Projects you finished months ago still hold all of it.

The short answer: node_modules folders and package caches are safe to delete: npm install (or pnpm, yarn, bun) brings back exactly what the lockfile lists. Use each package manager's own clean command for its cache.

On this page

  1. How do I find all node_modules folders?
  2. Is it safe to delete node_modules?
  3. Which package caches can I clear, and how?
  4. What about build folders?
  5. What should I keep?

How do I find all node_modules folders?

Point this at the folder where your code lives. It lists every node_modules with its size, biggest last:

find ~/Projects -type d -name node_modules -prune -exec du -sh {} + 2>/dev/null | sort -h

-prune keeps it from counting the node_modules inside other node_modules. Move the ones of old projects to the Trash in Finder, or delete them with rm -rf (no undo).

Is it safe to delete node_modules?

Yes. It holds downloaded packages, and your package.json and lockfile say which ones. Running npm install in the project restores them. Two exceptions: packages you edited by hand inside node_modules (use patch-package or your package manager's patch command instead) and working offline.

Which package caches can I clear, and how?

  • npm (~/.npm/_cacache): npm cache clean --force
  • pnpm (~/Library/pnpm/store): pnpm store prune removes packages no project uses
  • Yarn (~/Library/Caches/Yarn, ~/.yarn/berry/cache): yarn cache clean
  • Bun (~/.bun/install/cache): bun pm cache rm
  • Homebrew (~/Library/Caches/Homebrew): brew cleanup
  • pip (~/Library/Caches/pip): pip cache purge; uv (~/.cache/uv): uv cache clean
  • Go: go clean -cache -modcache
  • CocoaPods: pod cache clean --all; Gradle (~/.gradle/caches), Maven (~/.m2/repository) and Cargo (~/.cargo/registry) can go to the Trash and download again
  • Playwright browsers (~/Library/Caches/ms-playwright): reinstall with npx playwright install

The next install of each project downloads what it needs again, so the first one after clearing is slower.

What about build folders?

Build output rebuilds itself too: .next, .turbo, dist and build in JavaScript projects, target in Rust and Maven, .build in Swift packages, Pods in CocoaPods projects (pod install restores them).

What should I keep?

  • Python virtual environments (.venv): a rebuilt one may differ, since packages installed by hand and versions that aren't pinned don't come back the same.
  • The Node.js version you use in nvm or fnm. Older versions in ~/.nvm/versions/node that no project needs can go.
  • Projects with uncommitted changes: before removing anything bigger than dependencies, check git status.

Bytewell finds these folders across your whole disk, groups them by project, flags projects you haven't touched in a while and shows each one's branch and whether it has uncommitted changes. Package caches get the right clean command, and everything else goes to the Trash, where it can be put back.

Download

Guides

  • Claude Code, Codex and Cursor disk usage: what's safe to cleanWhere Claude Code, Codex, Gemini CLI, Cursor and VS Code keep transcripts, worktrees, runtimes and editor state on a Mac, and which of it you can safely remove.
  • Docker using too much disk space on a Mac: Docker.raw explainedDocker Desktop keeps everything in one file, Docker.raw. Why it looks huge, how to see what uses it, and which docker prune commands free space safely on Mac.
  • Where Ollama, LM Studio and Hugging Face store models on a MacWhere Ollama, LM Studio and Hugging Face keep local AI models on a Mac, how big they get, how to find the same model stored twice, and how to remove them.
  • How to check your Mac's SSD health and wearmacOS only says S.M.A.R.T. Verified. How to read your Mac SSD's real wear (Percentage Used, data written, errors), what the numbers mean, and what wears it out.
  • What is System Data on a Mac, and how do I make it smaller?System Data in Mac storage settings is caches, logs, Time Machine snapshots, swap, iPhone backups, app data and VM disks. What each is and what you can remove.
  • Videos or GIFs on X are black in SafariVideos and GIFs on X (Twitter) black in Safari while the timer runs, fine in Chrome? Safari's video helper is stuck. Quit Safari with Cmd+Q and reopen it.
  • Xcode taking up too much space: what's safe to deleteWhere Xcode keeps DerivedData, simulators, runtimes, device support and archives on a Mac, which of them rebuild themselves, and how to remove them safely.
Refunds Privacy Terms Contact

Bytewell is made by Axleno.

© 2026 Axleno LLC. All rights reserved.