Guide

How to delete node_modules from all your projects on a Mac.

Every JavaScript project keeps its own copy of thousands of packages. Old projects can quietly hold tens of gigabytes. Here are three ways to get that space back — and the mistakes to avoid.

First: is node_modules safe to delete?

Usually, yes. node_modules is fully regenerated by npm install (or yarn / pnpm install) from your package.json and lockfile. What you actually pay is reinstall time and network access the next time you open the project. The exceptions worth knowing:

Option 1: a find one-liner

List every node_modules folder under your projects directory and how big each one is:

find ~/Projects -name node_modules -type d -prune -exec du -sh {} +

Then delete them all:

find ~/Projects -name node_modules -type d -prune -exec rm -rf {} +

The risk: rm -rf is immediate and unrecoverable — there is no Trash, no undo. The command doesn't know whether a folder belongs to a real project, whether the project still installs, or whether you meant to include that path. One mistyped directory and the command happily deletes it.

Option 2: npkill

npkill is a popular free CLI that lists node_modules folders and lets you delete them interactively:

npx npkill

It's a solid tool for exactly this one job. Its limits: it only knows about node_modules (not build outputs, Python caches, or Xcode data), deletion is permanent rather than via Trash, and it doesn't check Git status or project context before deleting.

Option 3: RepoSweep

RepoSweep is a macOS app built for this cleanup across all your project types, with safety as the core feature:

Scanning is free and unlimited, so you can see exactly how much space is recoverable before paying anything. Download RepoSweep for macOS 14+ or see pricing — a one-time $12, no subscription.

Which should you use?

If you only ever accumulate node_modules and are comfortable with permanent deletion, npkill does the job. If your disk is filled by a mix of JavaScript, Python, Xcode, and other build artifacts — or you want deletions to be reversible — that's the case RepoSweep was built for.

Free to scan

See how much space your projects are hiding.

Download RepoSweep