Developer storage
How to Find and Delete node_modules Folders on Mac
Every JavaScript project you cloned may have left a node_modules folder behind. Many of them are sitting unused.
Short answer

On this page
Is it always safe to delete node_modules?
Usually, after review. Confirm the selected folder really is node_modules and contains no unique local edits or linked development work you need. Reinstallation depends on the lockfile, package availability, network or cache access, and any private-registry credentials. It is not guaranteed just because a project has a manifest.

Why do node_modules folders get so large?
Modern JavaScript projects often have deep dependency trees, and different tools (npm vs yarn vs pnpm) handle deduplication differently. A single project can easily accumulate hundreds of megabytes to a few gigabytes, and if you've cloned or scaffolded many projects over the years, those add up across your whole drive without you ever revisiting them.

What's the fastest way to find every node_modules folder on my Mac?
Terminal's find command works but can be slow across a whole drive and only lists folders without sizes. A disk-space analyzer can show recognized, readable node_modules folders and their sizes for review. Coverage and search time depend on permissions, the scan, and your disk.

What’s safe to delete?
node_modules in projects you're not actively working on
SafeAny project folder
Reinstallable via `npm install` / `yarn` / `pnpm install`, which needs network access.
How: Review the exact path and use Finder's Move to Trash for the dependency folder. Keep the project source, manifest, and lockfile.
node_modules in active, offline-needed projects
Review firstCurrent project folder
You'll need to reinstall before your next build; fine if you have network access, risky if you're about to go offline.
How: Only delete if you can reinstall before you need the project again.
pnpm's global content-addressable store
Review first~/Library/pnpm/store (or similar)
Shared across projects; clearing it means future installs re-download packages instead of linking from the store.
How: Use pnpm store prune rather than deleting the folder directly.
Keep the lockfile
Keep package.json and the lockfile, plus any install flags and registry configuration the project needs. A lockfile records dependency versions, but unavailable packages, credentials, local edits, or platform-specific builds can prevent an identical reinstall.
Do it manually
No app needed. These steps use Finder, Terminal, and each tool’s own settings.
- 1
Find node_modules folders and their sizes using Terminal.
$find ~ -type d -name node_modules -prune -exec du -sh {} \;This can take a while on a large drive and only searches your home folder.
- 2
Move a specific one you've confirmed you don't need to the Trash.
$open /path/to/projectIn Finder, select only node_modules and press ⌘⌫. Double-check you selected the dependency folder, not the project.
- 3
Reinstall when you need the project again.
$npm install
The Diskfern way
How Diskfern helps
Diskfern recognizes node_modules as one of its 44 Smart Highlight categories, so you don't need to hunt for them one project at a time.
- Scan your Mac with Diskfern.
- Open Smart Highlights and select node_modules to see every instance across your whole drive, with real sizes.
- Sort by size to find the heaviest, often-forgotten projects first.
- Review and move the ones you don't need right now to the Trash.
Finding and reviewing is free. Moving items to the Trash from Diskfern is part of Pro.
Find every node_modules folder on your MacQuestions
Will deleting node_modules lose my code?
Can I delete node_modules for a project I plan to open later?
Does every project's node_modules duplicate the same packages?
Is there a safer alternative to deleting node_modules manually?
Written by
Diskfern Team
We explain Mac storage using product behavior and the sources listed below. Review your app settings and backups before removing data.
Sources
- npm Docs: Lockfile-based clean installation · checked October 19, 2026
- pnpm Documentation: Motivation and store · checked October 3, 2026
Keep reading
Explore more developer storage guides, cache management, and tools.
Docker taking up space on Mac
Why Docker.raw is huge on Mac, how much of it is really used, and how to reclaim disk space with prune and Docker Desktop settings.
Clear Xcode storage
Xcode's DerivedData, device support files, old archives, and unused simulators can quietly use tens of gigabytes. Here's what's safe to delete and how.
Find large files on Mac
Finder's search can find large files, but it's slow and easy to misuse. Here's how to find them properly, plus faster methods for big drives.
Developer storage feature
Bring Xcode, Android, Docker, package caches, and local AI models into one readable map.
Get your space back. Start with a free scan.
Explore the files and folders Diskfern can read. Your files stay on your Mac, and nothing is removed until you say so.
macOS 14 Sonoma or later · Apple silicon and Intel