KlystorDownload

Clean up node_modules, npm caches, Docker and Xcode without breaking your projects

On a developer machine, documents are not what fills the disk: dependencies, builds and images are. Almost all of it rebuilds with one command.

6 min readUpdated

01The rule before any cleanup

A folder such as node_modules or target rebuilds itself, provided it really is the tool’s output and not a folder you worked in. Check that Git ignores it and that your work is saved:

git check-ignore -v node_modules
git status --short

If git check-ignore prints nothing, the folder is not ignored: do not delete it without looking at what it contains.

02JavaScript: node_modules, npm, pnpm, Yarn

To find the heaviest node_modules in a projects folder:

find ~/Projects -name node_modules -type d -prune -exec du -sh {} +

Delete those of inactive projects; an npm install (or pnpm install) rebuilds them. Global caches are cleared with:

npm cache clean --force
pnpm store prune
yarn cache clean

03Rust, Python, Java

  • Rust: a project’s target folder quickly exceeds several GB. cargo clean deletes it, the next build recreates it.
  • Python: a virtual environment (.venv) is rebuilt from requirements.txt or pyproject.toml; pip’s cache is cleared with pip cache purge.
  • Java and Android: ~/.gradle/caches and ~/.m2/repository download again on the next build, at the cost of a slower first build.

04Xcode and simulators

~/Library/Developer/Xcode/DerivedData holds intermediate builds: delete its contents with Xcode closed, it is rebuilt on the next build. Simulators for old iOS versions and device symbols are often the largest:

xcrun simctl delete unavailable

Folders in ~/Library/Developer/Xcode/iOS DeviceSupport for iOS versions you no longer use can go too; they are rebuilt when a device is connected.

05Docker

Start by seeing what takes up space, then clean up step by step:

docker system df
docker image prune
docker builder prune

docker image prune removes unnamed images with no container, docker builder prune the build cache. Avoid docker system prune -a --volumes without thinking: --volumes also erases the data of your local databases.

Klystor

All of this, safely and in minutes

Klystor measures your disk, explains every item and only offers what rebuilds itself or what you choose. A dry run before every deletion, the Trash by default. Free during the beta, for macOS, Windows and Linux.

Need help?