ScrubsDownload

Guides › Mac folder guide · updated

Is it safe to delete node_modules folders on a Mac?

<project>/node_modules

By Parsa Nasirimehr

Yes, for projects you aren't working on. node_modules only holds packages installed from the project's package.json and lockfile; npm install, yarn or pnpm install puts them back exactly.

How big it gets

On the Mac we measured, a working developer's Mac on macOS 27: 0.3 GB in 2 projects here; on Macs with many old web projects, they easily add up to tens of gigabytes.

What it is

What writes itnpm install, yarn, pnpm install or bun install, inside each project folder.
Why it adds upEvery project keeps its own copy, often 200 MB to 1 GB, and old projects keep theirs forever.
pnpm is differentpnpm hard-links packages from its shared store, so deleting a project's node_modules frees less than its size suggests.
Comes back?Yes, with the install command, as long as the project's package.json and lockfile are still there.

How to clear it

  1. List them with sizes, from a folder holding your projects: find . -name node_modules -type d -prune -exec du -sh {} +
  2. Delete the ones in projects you haven't touched for a while.
  3. Package caches are separate: npm cache clean --force, yarn cache clean, pnpm store prune.

What you lose: Nothing, as long as the lockfile stays. Reinstalling needs the network.

With Scrubs: Scrubs's Quick Wins finds node_modules in projects with nothing changed for 30 days and moves the ones you pick to the Trash. Download Scrubs; scanning is free.

Related folders

Sizes measured with du on 1 November 2026. Paths and commands apply to macOS 15 and later. See also how to free up disk space on a Mac.

About the author: Parsa Nasirimehr is a mobile app developer who builds Scrubs, a disk map for the Mac. Spotted something wrong? Write to support@getscrubs.app.