How to find and delete old node_modules on Mac

4 min readYou recover: 3–20 GBUpdated: 2026-09-29

Each node_modules weighs between 300 MB and 3 GB. With 20 local repos you easily carry 10–20 GB of dependencies you can reinstall with npm install. Git worktrees make it worse: each one has its own copy.

Find them all

Replace ~/workspace with the folder where you keep your projects:

find ~/workspace -name node_modules -type d -prune -exec du -sh {} + 2>/dev/null | sort -rh | head -20

Only delete the ones from inactive projects

Regenerates, with a cost

A good rule: if a project hasn't changed in more than 90 days, its node_modules is a candidate. Don't delete the one for the project you're working on right now: you'll just wait for the reinstall.

To delete one:

rm -rf ~/workspace/old-project/node_modules

Interactive tool

npkill lists all your node_modules and lets you delete them with the space bar:

npx npkill -d ~/workspace

Don't forget build artifacts

Safe

.next, dist, build, .turbo, target and .venv also regenerate. In Next.js projects, the .next folder can reach several GB.

FAQ

Do I lose anything if I delete node_modules?

No, as long as you have package.json and the lockfile. It reinstalls exactly the same with npm install, pnpm install or yarn.

Does pnpm save space?

Yes: pnpm stores each package once in a global store and links it into every project. But that store grows too; clean it with pnpm store prune.

Keep reading