Delete old node_modules folders
Last updated November 21, 2026
Every JavaScript project keeps its own node_modules folder, and old experiments, tutorials and forks keep theirs long after you stop opening them. Each one is safe to delete: an install brings it back.
Why it’s safe to delete
node_modules holds the packages a project depends on, downloaded from the npm registry as its package.json and lockfile list them. Delete it, and npm install, or the same command for pnpm, Yarn or Bun, downloads them again.
Keep the lockfile, package-lock.json, pnpm-lock.yaml, yarn.lock or bun.lock, so the install brings back the same versions. Two cases need a second thought: a project you’re running right now needs its node_modules, and if anyone edited a package inside it by hand, the edit goes with it.
Find them, with their sizes
This lists every node_modules folder in your home folder with its size, the biggest last. It skips apps, your Library folder and hidden folders like ~/.npm and ~/.vscode, where tools keep packages of their own:
find ~ \( -name ".*" -o -name "*.app" -o -path ~ /Library \) -prune -o -name node_modules -type d -prune -exec du -sh {} + 2> /dev /null | sort -hIt can take a few minutes on a full disk, and macOS may ask whether Terminal can see your Documents, Desktop or Downloads folder.
Delete the ones you don’t need
To delete one project’s node_modules, run this inside the project’s folder:
rm -rf node_modulesTo clear a whole folder of old projects at once, go into that folder in Terminal and run this. It deletes every node_modules inside it, and nothing else:
find . -name node_modules -type d -prune -exec rm -rf {} +Run it in a folder of projects, never in your home folder, where it would also reach the hidden folders tools keep their own packages in.
Other build folders that come back
Other tools keep folders like this in your projects too. Each comes back with the project’s next build or install:
.next,.nuxt,.svelte-kit,.angular,.expoand.docusaurus: what frameworks build, and their caches.turboand.parcel-cache: build cachestargetbeside aCargo.toml: Rust builds.buildbeside aPackage.swift: Swift package buildsPodsbeside aPodfile: CocoaPods, back withpod install.venvorvenv: Python virtual environments, made again from the project’s requirements.gradlebeside abuild.gradle, and.dart_toolbeside apubspec.yaml: Gradle and Dart
How Diskwise handles them
Diskwise’s free scan finds node_modules and every folder above in the projects in your home folder, grouped by project, with the day each project last changed. They’re Rebuildable: projects you changed in the last week stay unticked, and Diskwise never deletes a project’s build folders while something is running in it.
Next.js caches get rows of their own, since they grow with no limit, and stay put while that project’s Next.js server runs.
Rather not do it by hand?
Diskwise finds what fills your Mac, from build data to caches, sizes it honestly and clears what’s safe in one click. The scan is free.