- Published on
Mac Clean-Up
- Authors
- Name
- Yair Mark
- @yairmark
Eventually, your Mac will start to run out of space especially if you have a Macbook Air or entry-level Pro. As a developer over the years node_modules
and other detritus can start to accumulate. By their nature, these things can be retrieved if they are actively used or they are often relics from old discarded/complete projects. With this in mind below is a list of some of the commands and things I do to free up some space.
Deleting Rebuildable Elements
For most of the below commands, you will need to go to the root of the folder that you put your code repos in.
Node.js
node_module
s
Delete find . -type d -name "node_modules" -exec rm -fr {} \;
Delete Npm and Yarn's Cache
yarn cache clean
npm cache clean
Docker
Be more careful here as containers can be more difficult to get back. In my experience docker containers over time tend to chew up a fortune of space and most of the containers accumulated are not currently used by any projects I am on:
- docker system prune -a
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v /etc:/etc spotify/docker-gc
The Nuclear Option
- Reset docker as suggested here: https://apple.stackexchange.com/a/273096/160022
Android
Android SDK
rm -fr ~/Library/Android/sdk/
Java
find . -type d -name "target" -exec rm -fr {} \;
Homebrew
- Cache:
rm -rf brew --cache
- Cleanup:
brew cleanup
- This can sometimes cause issues with
brew doctor
it gives an error similar to:cannot load such file -- active_support/core_ext/object/blank
* To fix this run:brew style
. If it is still not fixed run:brew update-reset
. This is covered in depth here
- This can sometimes cause issues with