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
node_modules is usually generated dependency data. Before removing it, keep the project manifest and lockfile, preserve local dependency edits, and confirm packages and credentials remain available for reinstall. An analyzer can locate readable node_modules folders by size; permissions can limit coverage.

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?
A normal node_modules folder contains installed dependencies. Check for unique edits, local links, or a nonstandard project layout before removing it. Select only that folder; do not remove the surrounding project or rely on Git to preserve uncommitted data.
Can I delete node_modules for a project I plan to open later?
Usually, if you preserve its manifest and lockfile and can still access all dependencies. Keep a working copy when the project depends on local changes, unavailable packages, private credentials, or offline builds.
Does every project's node_modules duplicate the same packages?
Often, yes, especially with npm and yarn's classic mode, since each project gets its own copy. pnpm reduces duplication with a shared store, but individual project folders can still be large.
Is there a safer alternative to deleting node_modules manually?
You can use your package manager's own cache-cleaning commands (like `npm cache clean` or `pnpm store prune`) for shared caches, and delete per-project node_modules folders directly for ones you're done with.
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
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