·Updated ·8 min read

node_modules Taking Up Space on Mac: How to Find and Delete Them

Old side projects leave huge dependency trees. Delete the folders — you can npm install again later.

Abandoned projects often hide the biggest node_modules trees.

JavaScript projects duplicate dependencies per folder. A few forgotten repos can outgrow your Photos library.

Finding them is the hard part; deleting a node_modules folder is safe if you still have package.json / lockfiles to reinstall.

Find node_modules

Spotlight-friendly Terminal search
find ~ -type d -name node_modules -prune 2>/dev/null

Or use DoomDisk Space Map / junk scanning to spot heavy project trees visually without memorizing paths.

Map-first beats deleting random folders under Documents.

Delete safely

  1. Confirm the project still has package.json (and ideally a lockfile).
  2. Quit any dev server using that tree.
  3. Move node_modules to Trash (or rm -rf inside that project only).
  4. Empty Trash when sure.

Keep future projects lean

  • Delete node_modules when archiving a repo.
  • Prefer pnpm/Yarn where disk sharing helps on large monorepos.
  • Clear global npm/Yarn caches occasionally if they balloon.

FAQ

Will deleting node_modules break git?

No. Dependencies are reinstalled from the lockfile / package.json.

What about .next or dist folders?

Also safe to delete for most apps — rebuild with your usual command.

Can DoomDisk find these?

Yes — Space Map and junk views surface large dependency trees by size.