node_modules
A node_modules folder is rebuilt by running npm install (or pnpm install or yarn) again, so it is safe to delete in projects you are not working on. To list the folders and their sizes, run:
find ~ -name node_modules -type d -prune -exec du -sh {} + 2>/dev/null | sort -h
Delete the ones in old projects, and keep the ones you need offline.
Package-manager caches
- npm:
npm cache clean --force - pnpm:
pnpm store pruneremoves packages no project uses. - Yarn:
yarn cache clean - Homebrew:
brew cleanupremoves old versions and downloads.
These caches are re-downloaded when needed, so the cost is a slower next install.
Docker
Docker Desktop stores images, containers and volumes in one large disk image. First see what uses space:
docker system df
Then remove what you do not need:
docker builder pruneclears the build cache.docker image pruneremoves dangling images; add-ato remove all unused images.docker system pruneremoves stopped containers, unused networks and dangling images.
Be careful with volumes. Volumes can hold database data. docker system prune --volumes deletes unused volumes for good. Check docker volume ls first.
Why Docker.raw does not shrink
Deleting images inside Docker frees space in Docker’s disk image, but the file on your Mac can stay large until Docker Desktop reclaims it. Restarting Docker Desktop or using its disk-usage settings usually shrinks it.
A safe order
- Measure first:
docker system dfand thefindcommand above. - Delete
node_modulesin inactive projects. - Clear package caches.
- Prune Docker build cache and dangling images before touching volumes.
sysZivo’s developer filters (Node.js, Docker, virtual machines and more) show these on the storage map with sizes, so you can see which projects hold the most before you run anything. Related: delete Xcode DerivedData safely and clear cache on Mac safely.
Questions people ask
Is it safe to delete node_modules?
Yes. Run npm install, pnpm install or yarn in the project to restore it. Keep it if you need to work offline.
How do I free space from Docker on a Mac?
Run docker system df to see usage, then docker builder prune and docker image prune. Check volumes before pruning them, because they can hold data.
Why does Docker.raw stay big after I delete images?
The disk image on your Mac does not always shrink right away. Restarting Docker Desktop or reclaiming space in its settings usually helps.