If you're using an Apple Silicon Mac (M1/M2/M3/M4) for development, you may eventually run into an annoying problem:
"Not enough storage to install the latest macOS update."
As developers, our Macs accumulate a surprising amount of temporary data over time:
- npm, Yarn, and pnpm caches
- Xcode DerivedData
- iOS Simulator data
- Metro caches
- Homebrew downloads
- Application logs
- Old iOS device support files
- iPhone/iPad backups
- Docker data
- Other development artifacts
The good news? You can often recover many gigabytes of storage without touching your actual projects.
This guide walks through some common places to look and clean up.
⚠️ Important: Don't blindly delete system files. Always check what's consuming your storage first.
🔍 1. Check Your Available Storage
Before deleting anything, check how much free space you actually have:
# Show free/used space on the main disk
df -h /
You can also inspect some common developer storage locations:
# Size of user caches
du -sh ~/Library/Caches 2>/dev/null
# Size of user logs
du -sh ~/Library/Logs 2>/dev/null
# Size of developer data (Xcode, simulators, etc.)
du -sh ~/Library/Developer 2>/dev/null
This gives you a quick idea of where your storage is going.
🧹 2. Clear User Cache Files
macOS and applications store temporary cache files in your user Library.
Check the size first:
du -sh ~/Library/Caches 2>/dev/null
Clean it (only if you're comfortable removing these user-level caches):
# Remove all user-level caches
rm -rf ~/Library/Caches/*
Clear user logs:
# Remove all user-level logs
rm -rf ~/Library/Logs/*
Most applications will recreate the cache files they need.
💡 It's generally better to close applications before removing their caches.
You don't normally need to restart your Mac after clearing user caches, but restarting can help ensure applications start cleanly.
📦 3. Clear the npm Cache
If you're a Node.js developer, your npm cache can grow considerably over time.
Check its size:
du -sh ~/.npm 2>/dev/null
Clean it:
# Force-clear the npm cache
npm cache clean --force
If you frequently work with React, Next.js, React Native, or Expo projects, it's worth checking your npm cache periodically.
🧶 4. Clear the Yarn Cache
Check its location:
# Print the Yarn cache directory
yarn cache dir
Clean it:
# Clear the Yarn cache
yarn cache clean
The exact cache location can vary depending on your Yarn version and configuration.
📦 5. Clean the pnpm Store
For pnpm users, the package store can become quite large.
Check where your store is located:
# Print the pnpm store path
pnpm store path
Prune packages that are no longer needed:
# Remove unreferenced packages from the store
pnpm store prune
This removes unreferenced packages from the pnpm store.
🍺 6. Clean Homebrew
Homebrew can accumulate old package versions and downloaded archives.
Check the Homebrew cache:
du -sh "$(brew --cache)" 2>/dev/null
Preview what Homebrew thinks can be cleaned (dry run):
# -n = dry run, nothing is deleted
brew cleanup -n
Clean up old downloads and versions:
# -s = also scrub the cache, including latest downloads
brew cleanup -s
💡 Prefer
brew cleanuporbrew cleanup -sover manually deleting Homebrew directories.
🍎 7. Clean Xcode DerivedData
For iOS developers, Xcode's DerivedData is often one of the biggest storage consumers.
Check your Developer directory:
du -sh ~/Library/Developer 2>/dev/null
Check DerivedData specifically:
du -sh ~/Library/Developer/Xcode/DerivedData 2>/dev/null
Remove it if it's taking up a lot of space:
# Delete all DerivedData contents (Xcode recreates them on next build)
rm -rf ~/Library/Developer/Xcode/DerivedData/*
Xcode will recreate the required build artifacts the next time you build your projects.
What is DerivedData?
Xcode stores things such as:
- Intermediate build files
- Build products
- Index data
- Generated files
- Other project-specific build artifacts
If you've worked on many Xcode projects over time, this directory can become surprisingly large.
💡 Cleaning DerivedData doesn't delete your source code or projects.
📱 8. Check iOS Device Support Files
If you develop iOS applications, check:
# Size of iOS device support files (note the escaped space)
du -sh ~/Library/Developer/Xcode/iOS\ DeviceSupport 2>/dev/null
Older iOS device support files can occupy significant space.
⚠️ Before deleting anything, make sure you don't need to debug devices running those older iOS versions.
⚛️ 9. Clean the React Native / Metro Cache
React Native developers can accumulate Metro cache files.
Remove common Metro and Haste Map temporary files:
# Remove Metro bundler cache files
rm -rf "$TMPDIR"/metro-*
# Remove Haste Map cache files
rm -rf "$TMPDIR"/haste-map-*
This can also be useful when troubleshooting strange Metro bundler behavior.
Metro will recreate its cache when needed.
🚀 10. Check Your Expo Data
If you're working with Expo, check:
du -sh ~/.expo 2>/dev/null
Don't automatically delete the entire directory. Expo can store local configuration and cached data there, so inspect it first.
If you know you don't need the contents, you can remove it:
# Deletes Expo's local cached/configuration data
rm -rf ~/.expo
⚠️ Only remove
~/.expoif you're comfortable losing its local cached/configuration data.
📱 11. Check Old iPhone/iPad Backups
iPhone and iPad backups can consume tens of gigabytes.
Check their size:
du -sh ~/Library/Application\ Support/MobileSync/Backup 2>/dev/null
If the directory is large, open it in Finder:
open ~/Library/Application\ Support/MobileSync/Backup
Review your backups before deleting anything.
⚠️ Don't delete backups you may need later.
🗑️ 12. Empty Your Trash
It sounds obvious, but files in the Trash still consume disk space.
You can empty your user Trash from Terminal:
# Permanently deletes everything in your Trash
rm -rf ~/.Trash/*
⚠️ This permanently deletes everything currently in your Trash. Make sure there's nothing you want to recover first.
🔎 13. Find the Real Storage Hogs
Instead of randomly deleting files, find out what's actually consuming your storage.
Start with your home directory:
# Size of each top-level folder, sorted smallest to largest
du -hd 1 ~ 2>/dev/null | sort -h
Then inspect your Library:
du -hd 1 ~/Library 2>/dev/null | sort -h
And specifically your Developer directory:
du -hd 1 ~/Library/Developer 2>/dev/null | sort -h
You might see something like:
2G ~/Library/Caches
8G ~/Library/Application Support
15G ~/Library/Developer
30G ~/Library
Now you know where to investigate instead of blindly deleting files.
🐳 14. Don't Forget Docker
If you use Docker for development, Docker can become one of the biggest consumers of disk space.
Check Docker's disk usage:
docker system df
This shows space used by:
- Images
- Containers
- Local volumes
- Build cache
Remove unused Docker data:
# Removes stopped containers, unused networks, dangling images
docker system prune
For a more aggressive cleanup:
# Also removes ALL unused images, not just dangling ones
docker system prune -a
⚠️ Be careful with Docker cleanup commands. Removing images, containers, or volumes can affect development environments.
⏱️ 15. Check macOS Local Time Machine Snapshots
Time Machine can maintain local APFS snapshots.
Check them with:
# List local APFS snapshots
tmutil listlocalsnapshots /
If you see many snapshots, investigate them before attempting to remove anything.
⚠️ Don't use random
rm -rfcommands against APFS snapshots. Use Apple's supported Time Machine/APFS tools and workflows.
🧹 My Developer Cleanup Checklist
If I'm trying to quickly recover space on a development Mac, I don't start by deleting everything.
Step 1: Inspect the biggest locations
# Free space on the main disk
df -h /
# Biggest folders inside Library
du -hd 1 ~/Library 2>/dev/null | sort -h
# Biggest folders inside Developer
du -hd 1 ~/Library/Developer 2>/dev/null | sort -h
Step 2: Clean the specific caches you know you don't need
# npm cache
npm cache clean --force
# pnpm store
pnpm store prune
# Homebrew downloads and old versions
brew cleanup -s
# Xcode build artifacts
rm -rf ~/Library/Developer/Xcode/DerivedData/*
# React Native / Metro caches
rm -rf "$TMPDIR"/metro-*
rm -rf "$TMPDIR"/haste-map-*
Step 3: User caches and logs (only if you've checked them first)
rm -rf ~/Library/Caches/*
rm -rf ~/Library/Logs/*
Step 4: Check your available storage again
df -h /
⚠️ DON'T Do This
You'll sometimes find advice online telling you to run commands like:
# ❌ NEVER run these
sudo rm -rf /Library/*
sudo rm -rf /System/*
sudo rm -rf /private/*
sudo rm -rf /var/*
Don't.
These aren't generic "cache folders." They contain files that macOS and installed software depend on.
A few minutes of aggressive cleanup isn't worth turning your Mac into a troubleshooting project. 😅
💡 A Better Approach
Instead of blindly deleting files, use this workflow:
1. Check available space
df -h /
2. Find the largest directories
du -hd 1 ~/Library 2>/dev/null | sort -h
3. Identify what you're comfortable removing
Common developer storage candidates include:
- npm cache
- Yarn cache
- pnpm store
- Homebrew cache
- Xcode DerivedData
- Metro cache
- Docker images and build cache
- Old iOS device support files
- Old iPhone/iPad backups
- User caches
- Old application logs
- Unused development tools and SDKs
4. Delete only unnecessary data
Don't remove something simply because it's large.
Large doesn't automatically mean unnecessary.
5. Check storage again
df -h /
6. Restart if necessary
A restart isn't required after every cleanup, but it can be useful after removing caches or large amounts of temporary data.
🚀 Final Tip
If you're trying to free space specifically because macOS won't let you install an update, don't immediately start deleting random system files.
First find out what's actually consuming your storage.
For developers, the usual suspects can include:
- Xcode
- iOS Simulators
- npm/pnpm/Yarn caches
- Docker
- Homebrew
- Old device backups
- Large application data
- Development SDKs and build artifacts
Your Mac doesn't necessarily need more storage.
Sometimes it just needs a little developer housekeeping. 🧹💻
If this guide helped you recover a few GB, bookmark it for the next time your Mac suddenly says:
"Your startup disk is almost full."
Top comments (0)