DevDuster

Find and delete old node_modules folders and clear the npm, Yarn, pnpm and Bun caches on your Mac, with commands and what is safe to remove.

Why node_modules gets so big

Every JavaScript project keeps its own copy of its dependencies in node_modules, often 200 MB to 1 GB each. Old side projects and tutorials keep theirs forever. On top of that, each package manager keeps a global download cache. Both are recreated by an install, so neither holds anything you cannot get back.

Find node_modules folders and their size

Run this in the folder that holds your projects (for example ~/Projects):

find . -name node_modules -type d -prune -exec du -sh {} + | sort -h

Delete them

Delete one project's folder with rm -rf node_modules inside it. To delete every one under the current folder:

find . -name node_modules -type d -prune -exec rm -rf {} +

This also removes them from projects you are working on today, and rm -rf skips the Trash. Run the size command first and check where you are.

Bring a project back with npm install, yarn, pnpm install or bun install.

Clear the package manager caches

ToolCacheCommand
npm~/.npm/_cacache, ~/.npm/_npxnpm cache clean --force
Yarn 1~/Library/Caches/Yarnyarn cache clean
Yarn 2+~/.yarn/berry/cacheyarn cache clean --all
pnpm~/Library/pnpm/storepnpm store prune
Bun~/.bun/install/cachebun pm cache rm

pnpm store prune removes only packages no project links to, so existing node_modules keep working.

How DevDuster handles node_modules

  • npm, Yarn, pnpm, Bun, Deno, node-gyp, TypeScript and Electron caches are in the safe tier.
  • node_modules is in review, and only removed when a package.json sits next to it and the project has had no activity for 14 days (changeable in Settings). Projects you are working on are left alone.
  • Items go to the Trash by default, so an install is not your only way back.

Do it in one pass. DevDuster is a free, open-source Mac cleaner for developers. It finds all of the above, shows exact paths and sizes, and moves only what you confirm to the Trash.

Every rule DevDuster ships, with its exact paths, is on What's safe to delete.