A node_modules folder holds the packages that one JavaScript project depends on. It is safe to delete in projects you are not actively running. Your package.json and lockfile stay, and npm install rebuilds the folder. Delete it in old projects first, where it is wasted space.
- Path
node_modules folders inside each JavaScript project- What it is
- Installed packages for one JavaScript or TypeScript project
- Typical size
- Hundreds of megabytes per project is common, and Macs with many projects can have tens of gigabytes in total
- Made by
- npm, Yarn or pnpm (run by you or by AI coding tools)
- Safe to delete?
- Safe to clear
- Comes back?
- Yes. Run npm install (or yarn or pnpm install) in the project
What is in this folder?
Every project that uses npm, Yarn or pnpm keeps its own node_modules, so a Mac with dozens of projects holds dozens of copies of the same packages. Copied project folders, git worktrees and AI-generated scaffolds make this worse because each copy keeps its own packages.
Some tools run code from node_modules, so deleting it while a dev server or watcher is running breaks that process.
Is it safe to delete?
Yes. The packages are fully described by package.json and the lockfile, so npm install or npm ci recreates the same versions. The cost is an install and a download, and offline you cannot rebuild it.
Be careful with two cases: folders you edited by hand to patch a package (use a patch tool instead next time), and node_modules folders inside editor extensions, which ship their own and stop working when cleared.
How do I clear it by hand?
- Stop the dev server or build in that project.
- Delete
node_modulesin the project folder. - Reinstall only when you return to the project.
cd ~/path/to/project
rm -rf node_modules
npm installOnly delete a project's ownnode_modules. Do not deletenode_modulesinside an app's bundle or an editor's extensions folder.
How do I stop it growing?
Use pnpm, which links packages from one shared store, and delete node_modules in projects you finish. Clean House can find them all at once.
How Clean House handles it
Clean House finds node_modules folders across your projects, lists each by project, and marks them as something that comes back when you reinstall. Packages inside a node_modules are treated as part of the project above them. It skips the node_modules inside editor extensions, because clearing those breaks the extension. Files go to the Trash.