Mac storage basics · Developer tools
How do I find and remove old node_modules folders?
Short answer: Use find . -name node_modules -type d -prune (with du -sh to size them) and delete ones in inactive projects; npm install recreates them from the lock file.
Every JavaScript project keeps its own node_modules, and old projects quietly hold gigabytes. To find them from a parent folder such as your projects directory, run find . -name node_modules -type d -prune in Terminal, and add -exec du -sh {} + to see sizes.
It's safe to delete node_modules in projects you're not working on; npm install (or your package manager's install) recreates it from the lock file when you return. Don't delete it in a project with no lock file if you need exactly the same versions back.