Guides

How to find what node_modules is using on your Mac

Find every node_modules folder on your Mac and see how much space each uses, why pnpm sizes mislead, and how to remove old ones without breaking live projects.

Last updated 25 October 2026. Cachelift is published by Brixfly.

Every JavaScript project keeps its own node_modules folder, and old projects keep theirs forever. A dozen forgotten projects can quietly use tens of gigabytes.

See the size of one project

du -sh node_modules

Find them all

This lists every node_modules folder under your Projects folder with its size. Change the path to wherever you keep code. The -prune stops it from counting folders nested inside each other.

find ~/Projects -name node_modules -type d -prune -exec du -sh {} + | sort -hr | head -20

A note on pnpm

If you use pnpm, the packages are stored once in a shared store and linked into each project. A project’s node_modules can look large without costing that much extra space, and removing it frees less than the number suggests. To clean up the shared store itself:

pnpm store prune

Is it safe to remove?

Removing node_modules does not touch your code. Running npm install or pnpm install in that project brings it back, using your lockfile so you get the same versions.

A good rule: remove it for projects you have not opened in months, and keep it for ones you are working on this week.

Review them with Cachelift

Cachelift lists the node_modules folders it finds across your Mac, with their sizes and when each project was last worked on. It treats them as review-first, so they are never selected for you. You choose which ones to move to the Trash.