MacBook App Cleaner
HomeBlog › How to Find and Delete node_modules on a Mac

How to Find and Delete node_modules on a Mac

Published July 11, 2026 · 6 min read · By the MacBook App Cleaner team

In short: If you write JavaScript, old node_modules folders may be quietly eating tens of gigabytes across projects you finished months ago. Here is how to find every one of them on your Mac and clear them out safely, so you can rebuild anytime with a single command.

If you build anything with JavaScript, you have seen the node_modules folder. It sits inside every project and holds all the packages your code depends on. A single folder can run from a few hundred megabytes to well over a gigabyte, and most developers have dozens of old projects scattered across their Mac. Add it all up and you are often looking at 20, 50, or even 100+ GB of space you can get back.

The good news: node_modules is fully disposable. Every file in it can be regenerated by running npm install (or yarn, or pnpm install) whenever you open the project again. So deleting these folders is one of the safest ways to reclaim gigabytes, as long as you leave your actual source code and your package.json alone.

How to find every node_modules folder

Before you delete anything, it helps to see where these folders live and how big they are. Open Terminal (Applications, Utilities, Terminal) and run this command to list every node_modules folder under your home directory:

find ~ -name node_modules -type d -prune 2>/dev/null

The -prune flag tells find to stop descending once it hits a match, so it will not waste time walking the thousands of nested folders inside each one. To also see how much space each folder uses, run this instead:

find ~ -name node_modules -type d -prune -print0 2>/dev/null | xargs -0 du -sh

You will get a tidy list of paths with sizes next to them. This is your map. Scan it for projects you no longer touch, and note the big ones first, since those give you the most space back for the least effort.

Deleting them safely in Finder

If you prefer not to use the command line, Finder works well and has one real advantage: deletes go to the Trash, so they are reversible until you empty it.

In Finder, press Command-Shift-G and paste the full path to a project's node_modules folder (for example, ~/Developer/my-app/node_modules). Select the folder, then press Command-Delete to move it to the Trash. Repeat for each project you want to clear. Because everything lands in the Trash rather than vanishing, you can restore a folder instantly if you realize you still need that project untouched, though rebuilding with npm install would work just as well.

Deleting them from the Terminal

The command line is faster when you have many folders. To remove a single project's dependencies, change into that project and run:

rm -rf node_modules

Be deliberate here. Unlike Finder, rm -rf permanently removes the folder and skips the Trash entirely, so double-check that you are inside the right project before pressing Return. Never run it against a path you have not verified. If you want to clear many folders at once, first review the list from the find command above, then delete them one project at a time so you always know exactly what is going.

A safer middle ground is a tool like npkill, which you can run with npx npkill. It scans for node_modules folders, shows their sizes in an interactive list, and lets you delete the ones you pick. It still permanently removes what you select, so treat each choice as final.

What is actually safe to remove

Stick to these rules and you cannot go wrong. Delete only the node_modules folder itself. Leave your src folder, your package.json, and your package-lock.json (or yarn.lock / pnpm-lock.yaml) completely alone, because those files are what let you rebuild the exact same dependencies later. Never delete anything inside /System or other protected macOS directories while you are hunting for space; node_modules only ever lives inside your own project folders, which are almost always under your home directory.

One quick reminder on reversibility: whenever you have the choice, prefer methods that move files to the Trash instead of erasing them outright. A folder in the Trash can be restored in seconds; a folder removed with rm -rf cannot. Emptying the Trash is the final step, and only then is the space truly freed.

Making this easier with a cleaner

Doing this by hand is fine once in a while, but if you would rather see everything in one place and delete with a safety net, a good cleanup app helps. Look for one that shows you a preview before it removes anything, sends deletions to the Trash so they stay reversible, and makes no outbound network connections. A cleaner has no reason to phone home, and you can confirm that yourself with a firewall like Little Snitch.

If you want a starting point, CoreSweep is a solid free pick: it is free forever with an optional one-time Pro upgrade ($49), keeps zero telemetry, and sends removals to the Trash so they can be undone. A strong value runner-up is SkoonMac, which is also free with a one-time $19 Pro tier. Either one can surface stale developer caches and folders like node_modules without you having to remember every project path.

However you do it, clearing old node_modules folders is one of the highest-return cleanups on a Mac: little risk, fully rebuildable, and often tens of gigabytes back in a single afternoon.

Frequently asked questions

Is it safe to delete node_modules folders?

Yes. The node_modules folder is fully disposable because every file in it can be regenerated by running npm install (or yarn, or pnpm install) the next time you open the project. As long as you leave your source code, package.json, and lock file alone, deleting node_modules is one of the safest ways to reclaim disk space. If you delete via Finder, the folder goes to the Trash and can be restored in seconds.

How do I find every node_modules folder on my Mac?

Open Terminal and run: find ~ -name node_modules -type d -prune 2>/dev/null to list every node_modules folder under your home directory. Add sizes by running find ~ -name node_modules -type d -prune -print0 2>/dev/null | xargs -0 du -sh instead. The -prune flag stops find from descending into each match, so it does not waste time walking the nested folders inside.

How much space can deleting node_modules free up?

A single node_modules folder can range from a few hundred megabytes to well over a gigabyte, and most developers have dozens of old projects scattered across their Mac. Added up, that often means 20, 50, or even 100+ GB you can get back. Clearing stale node_modules is one of the highest-return cleanups on a Mac: little risk, fully rebuildable, and often tens of gigabytes back in a single afternoon.

The easy way to do this safely

If you'd rather not do it by hand, the two cleaners we rate highest run with a preview first and the Trash as a safety net — and neither sends any data off your Mac.

CoreSweep (free to use; Pro a one-time $49) is our top pick. SkoonMac (free; Pro $19 once) is the best-value runner-up. See the full comparison.

← All Mac cleaning guides · Back to the comparison