How to delete node_modules safely
Every abandoned side project leaves a node_modules tree. Deleting is safe for projects you are not running today — npm/pnpm/yarn will recreate it — but wipe the wrong folder and you waste a reinstall.
Find the heavy ones
# from your code root du -sh */node_modules 2>/dev/null | sort -hr | head
Or run devdisk, which groups every package.json’s node_modules and marks them Review first.
Delete one project
cd /path/to/project rm -rf node_modules # later: npm install # or pnpm i / yarn
Many projects
Prefer a report over a blanket find-delete. Blind find ~ -name node_modules -exec rm -rf {} + can hit tools you still need and is hard to undo.
devdisk builds a commented script for review items so you uncomment only what you mean.
Also clear the package cache
After pruning projects, package managers still keep caches:
npm cache clean --force pnpm store prune yarn cache clean
devdisk lists these under Safe to regenerate.
FAQ
Is deleting node_modules safe?
Yes for projects you are not actively developing. You need a lockfile (or package.json) and network to reinstall.
Why is it so large?
Nested dependencies, optional native binaries, and duplicated trees across projects. pnpm helps; old npm trees do not.
Does devdisk delete for me?
No. Read-only. You copy or download a script and run it yourself after reading every line.