node_modules folders are safe to delete: they hold installed packages, and npm install (or pnpm, yarn, bun install) puts them back from package.json. List them with find ~/Projects -name node_modules -type d -prune -exec du -sh {} + | sort -h, then remove old ones, or use npx npkill to pick them interactively.
- List every node_modules folder under your projects folder with its size.
- Pick projects you haven’t worked on lately.
- Delete their node_modules with npkill or by moving them to the Trash.
- Run npm install (or your package manager’s install) when you return to a project.
- Prune the shared package caches too: npm cache clean --force, pnpm store prune.
Why node_modules adds up
Every project installs its own copy of its dependencies. A typical web app's node_modules is 200 MB to 1 GB, and dozens of old projects, tutorials and clones quickly add up to tens of gigabytes. Nothing removes them when you stop working on a project.
Step 1: List them, with sizes
Replace ~/Projects with wherever you keep code:
find ~/Projects -name node_modules -type d -prune -exec du -sh {} + | sort -h-prune stops find from descending into nested node_modules, so each project is listed once. The biggest are at the bottom. This command only reads.
Step 2: Delete the ones you don't need
Interactive (recommended): npkill lists every node_modules with its size and age, and deletes the one you select with the space bar.
npx npkill -d ~/ProjectsBy hand: drag a project's node_modules folder to the Trash in Finder, so you can still take it back.
rm -rf skips the Trash. If you script deletions with find and rm, run the listing command first and read it.
Let Tidy Mac do this for you
See every part of your storage explained, and clear junk to the Trash with Undo. $9.99 once, 2 Macs.
Step 3: Reinstall when you return
In the project folder, run npm install (or pnpm install, yarn, bun install). The lockfile brings back the same versions.
Don't forget the shared caches
Package managers also keep a global cache of everything they ever downloaded:
npm cache clean --force
pnpm store prune
yarn cache cleanWhere each cache lives · The pnpm store
Where Tidy Mac fits
Tidy Mac's Clean screen has a Project folders list: node_modules, build output (.next, dist, target) and tool caches in projects you haven't touched lately. It only lists a folder when the project's manifest (package.json, Cargo.toml, Podfile) sits next to it, never touches your source, and moves what you clear to the Trash with Undo. See what's included · Pricing
Frequently asked questions
Is it safe to delete node_modules?
Yes. It only holds installed packages. Running npm install (or your package manager’s install command) in the project rebuilds it from package.json and the lockfile.
How do I see how much space node_modules uses on my Mac?
Run find ~/Projects -name node_modules -type d -prune -exec du -sh {} + | sort -h. It lists each folder with its size, biggest last.
Does deleting node_modules delete my code?
No. Your source files, package.json and lockfile stay. Only the installed dependencies are removed.
Does pnpm save space compared with npm?
Usually. pnpm keeps one copy of each package version in its store and hard-links it into each project, so many projects share the same files. The pnpm store