The Ultimate Developer's Guide: Free Up 50GB+ by Cleaning Development Projects

Free Up 50GB+ Storage: Complete Guide to Clean Flutter, Node.js, Android & iOS Projects | Developer Cleanup Commands
The Ultimate Developer's Guide: Free Up 50GB+ by Cleaning Development Projects

Reading Time: 15-20 minutes
Difficulty Level: Beginner to Intermediate
Storage Potential: 10-100GB+ freed



Table of Contents

  1. Introduction: The Storage Crisis Every Developer Faces
  2. Understanding What's Consuming Your Storage
  3. Prerequisites: What You Need to Know
  4. Part 1: Cleaning Flutter Projects - Complete Command Guide
  5. Part 2: Cleaning Node.js Projects - Complete Command Guide
  6. Part 3: Cleaning Android/Kotlin/Java Projects - Complete Command Guide
  7. Part 4: Cleaning iOS/Swift Projects - Complete Command Guide
  8. Part 5: System-Wide Cache Cleanup - Maximum Storage Recovery
  9. Part 6: Finding and Cleaning All Projects at Once
  10. Safety Guidelines: What's Safe to Delete
  11. Troubleshooting: Common Issues and Solutions
  12. Best Practices: Maintaining a Clean Development Environment
  13. FAQ: Your Questions Answered
  14. Conclusion: Reclaim Your Storage Today


Introduction: The Storage Crisis Every Developer Faces

The Problem

Your Mac's storage is disappearing. One day you have 200GB free, the next you're seeing "Your disk is almost full" warnings. As a developer working with Flutter, Node.js, Android, or iOS projects, you're creating gigabytes of build artifacts, caches, and dependencies every single day.

The Reality

  • A single Flutter project can accumulate 500MB-2GB in build files
  • Node.js projects with node_modules can consume 100MB-1GB each
  • Android projects with Gradle caches can reach 2-5GB per project
  • iOS projects with Xcode DerivedData can use 1-3GB each

Multiply this by 20+ projects, and you're looking at 50-100GB+ of wasted storage.

The Solution

This guide provides every single command you need to clean your development projects. Each command is explained in detail, so you understand exactly what it does and why it's safe to run.



Understanding What's Consuming Your Storage

What Are Build Artifacts?

Build artifacts are temporary files created when you compile, build, or run your projects. They include:

  • Compiled binaries: Machine-readable code generated from your source
  • Cache files: Stored data to speed up future builds
  • Dependencies: Third-party libraries downloaded and stored locally
  • Intermediate files: Temporary files created during the build process

Why Can We Delete Them?

Build artifacts are regenerated automatically when you build your project again. Your source code, configuration files, and project structure remain untouched. Think of it like clearing your browser cache - the websites still work, but temporary files are removed.

Storage Breakdown by Project Type

Project Type Typical Size What's Consumed
Flutter 500MB-2GB Build outputs, Dart cache, iOS Pods, Android builds
Node.js 100MB-1GB node_modules, build caches, framework outputs
Android 500MB-3GB Gradle cache, build outputs, IDE caches
iOS 500MB-2GB DerivedData, CocoaPods, build products



Prerequisites: What You Need to Know

Required Knowledge

  • Basic terminal usage: Ability to open Terminal (macOS/Linux) or Command Prompt/PowerShell (Windows)
  • File navigation: Understanding of folder structures
  • Copy-paste skills: You'll be copying commands into your terminal

Required Tools

  • Terminal/Command Line: Built into macOS and Linux
  • Text Editor: To view and understand commands (optional)

Optional Tools (For Automatic Cleanup)

  • Flutter SDK: For flutter clean command (if you have Flutter projects)
  • Node.js/npm: Usually not needed for cleanup, but helpful for verification
  • Git: Recommended for backing up work before cleanup

Safety First

Always commit your work to Git before running cleanup commands:

git add .
git commit -m "Save work before cleanup"

This ensures you have a backup if anything goes wrong (though cleanup commands are designed to be safe).



Part 1: Cleaning Flutter Projects - Complete Command Guide

Flutter projects accumulate build artifacts across multiple platforms (iOS, Android, Web, Desktop). Here's how to clean them systematically.

Command 1.1: Navigate to Your Flutter Project

What this does: Changes your current directory to your Flutter project location.

Command:

cd /path/to/your/flutter/project

Explanation:

  • cd stands for "change directory"
  • Replace /path/to/your/flutter/project with your actual project path
  • Example: cd ~/Documents/code/my_flutter_app

How to find your project path:

  1. Open Finder (macOS) or File Manager
  2. Navigate to your Flutter project folder
  3. Right-click the folder and select "Get Info" (macOS) or "Properties" (Windows)
  4. Copy the path shown

Expected output: No output means success. You're now in your project directory.



Command 1.2: Verify You're in a Flutter Project

What this does: Confirms you're in the correct directory by checking for Flutter project files.

Command:

ls -la | grep pubspec.yaml

Explanation:

  • ls -la lists all files (including hidden ones) with details
  • | pipes the output to the next command
  • grep pubspec.yaml searches for the Flutter configuration file

Expected output: You should see pubspec.yaml in the list. If not, you're not in a Flutter project directory.

Alternative (simpler):

ls pubspec.yaml

If the file exists, you'll see pubspec.yaml. If not, you'll get an error.



Command 1.3: Run Flutter Clean (Primary Cleanup)

What this does: Removes all Flutter build artifacts using Flutter's built-in cleanup command.

Command:

flutter clean

Explanation:

  • flutter is the Flutter SDK command-line tool
  • clean removes build directories and caches
  • This is the safest and recommended way to clean Flutter projects

What gets deleted:

  • build/ directory (all platform builds)
  • .dart_tool/ directory (Dart analyzer cache)
  • .flutter-plugins file (generated plugin registry)
  • .flutter-plugins-dependencies file (plugin dependencies)

What's preserved:

  • ✅ All source code in lib/
  • pubspec.yaml (dependencies configuration)
  • ✅ Assets and resources
  • ✅ Configuration files

Expected output:

Cleaning Xcode workspace...
Deleting .dart_tool...
Deleting Generated.xcconfig...
Deleting flutter_export_environment.sh...

Time taken: 5-30 seconds depending on project size.

If Flutter is not installed:
You'll see: command not found: flutter
Solution: Install Flutter from flutter.dev or skip to manual cleanup commands below.



Command 1.4: Remove iOS Build Artifacts (Manual)

What this does: Manually removes iOS-specific build files that flutter clean might not remove completely.

Command:

rm -rf ios/Pods ios/Podfile.lock ios/build

Explanation:

  • rm stands for "remove"
  • -r means recursive (delete folders and contents)
  • -f means force (don't ask for confirmation)
  • ios/Pods is the CocoaPods dependencies folder (can be 500MB-1GB)
  • ios/Podfile.lock is the lock file for CocoaPods versions
  • ios/build contains Xcode build outputs

Safety: This only removes iOS build files. Your iOS source code and configuration remain intact.

Expected output: No output means success.

Storage freed: Typically 500MB-1.5GB for projects with iOS support.



Command 1.5: Remove Android Build Artifacts (Manual)

What this does: Removes Android-specific build files and Gradle cache.

Command:

rm -rf android/build android/.gradle android/app/build

Explanation:

  • android/build contains Android build outputs
  • android/.gradle is the local Gradle cache for this project
  • android/app/build contains app-specific build artifacts

Safety: Only removes build files. Your Android source code in android/app/src/ is preserved.

Expected output: No output means success.

Storage freed: Typically 200MB-800MB for Android projects.



Command 1.6: Remove All Build Directories (Comprehensive)

What this does: Finds and removes ALL build directories in your Flutter project, including nested ones.

Command:

find . -type d -name "build" -exec rm -rf {} +

Explanation:

  • find . searches from current directory
  • -type d looks for directories only
  • -name "build" matches directories named "build"
  • -exec rm -rf {} + executes remove command on each found directory
  • {} is replaced by each found directory
  • + processes multiple files efficiently

Safety: Only removes directories named "build". Your source code is safe.

Expected output: No output means success (or "No such file or directory" if no build folders exist).

Alternative (safer, shows what will be deleted first):

# First, see what will be deleted
find . -type d -name "build"

# Then delete if the list looks correct
find . -type d -name "build" -exec rm -rf {} +


Command 1.7: Remove Dart Tool Cache

What this does: Removes Dart analyzer and build runner cache files.

Command:

rm -rf .dart_tool

Explanation:

  • .dart_tool/ contains Dart analyzer cache, build runner outputs, and other tooling files
  • The dot (.) prefix makes it a hidden directory
  • This cache speeds up analysis but can be safely deleted

Expected output: No output means success.

Storage freed: Typically 10MB-100MB.



Command 1.8: Verify Flutter Cleanup

What this does: Checks if cleanup was successful by looking for remaining build directories.

Command:

find . -type d \( -name "build" -o -name ".dart_tool" \) 2>/dev/null

Explanation:

  • find . searches from current directory
  • -type d looks for directories
  • \( -name "build" -o -name ".dart_tool" \) matches directories named "build" OR ".dart_tool"
  • 2>/dev/null hides error messages

Expected output:

  • Empty output = Cleanup successful! No build directories found.
  • Directory names listed = Some build directories still exist (may be intentional for active development).


Command 1.9: Restore Flutter Dependencies (After Cleanup)

What this does: Re-downloads Flutter package dependencies after cleanup.

Command:

flutter pub get

Explanation:

  • pub is Flutter's package manager
  • get downloads dependencies listed in pubspec.yaml
  • This restores packages needed for development

Expected output:

Running "flutter pub get" in my_flutter_app...
Resolving dependencies...
Got dependencies!

Time taken: 10-60 seconds depending on number of dependencies.

When to run: After cleanup, before building your project again.



Flutter Cleanup Summary

Commands to run in order:

  1. cd /path/to/flutter/project - Navigate to project
  2. flutter clean - Primary cleanup (if Flutter installed)
  3. rm -rf ios/Pods ios/Podfile.lock ios/build - Clean iOS (if applicable)
  4. rm -rf android/build android/.gradle - Clean Android (if applicable)
  5. flutter pub get - Restore dependencies

Total storage typically freed: 500MB - 2GB per Flutter project



Part 2: Cleaning Node.js Projects - Complete Command Guide

Node.js projects are notorious for large node_modules folders. Here's how to clean them effectively.

Command 2.1: Navigate to Your Node.js Project

What this does: Changes to your Node.js project directory.

Command:

cd /path/to/your/node/project

Explanation: Same as Flutter - replace with your actual project path.

Example:

cd ~/Documents/code/my_nextjs_app


Command 2.2: Verify You're in a Node.js Project

What this does: Confirms you're in a Node.js project by checking for package.json.

Command:

ls package.json

Explanation:

  • package.json is the Node.js project configuration file
  • If it exists, you're in a Node.js project

Expected output: package.json (file name) or error if not found.



Command 2.3: Check Size of node_modules (Before Cleanup)

What this does: Shows how much space node_modules is consuming.

Command:

du -sh node_modules 2>/dev/null || echo "node_modules not found"

Explanation:

  • du stands for "disk usage"
  • -s shows summary (total size)
  • -h makes it human-readable (MB, GB)
  • 2>/dev/null hides errors if folder doesn't exist
  • || echo "..." shows message if folder not found

Expected output:

245M    node_modules

This shows node_modules is using 245 megabytes.

Why check first: So you know how much storage you'll free up.



Command 2.4: Remove node_modules (Primary Cleanup)

What this does: Deletes the entire node_modules folder containing all npm package dependencies.

Command:

rm -rf node_modules

Explanation:

  • node_modules/ contains all installed npm packages
  • This is the biggest storage consumer in Node.js projects
  • Safe to delete - can be restored with npm install

What gets deleted:

  • All npm package files and dependencies
  • Nested dependencies (dependencies of dependencies)
  • Package binaries and executables

What's preserved:

  • package.json (dependency list)
  • package-lock.json (exact versions)
  • ✅ All source code
  • ✅ Configuration files

Expected output: No output means success.

Time taken: 5-30 seconds depending on size.

Storage freed: Typically 100MB-1GB, sometimes more for large projects.



Command 2.5: Remove Next.js Build Cache

What this does: Removes Next.js build output and cache (if using Next.js framework).

Command:

rm -rf .next

Explanation:

  • .next/ is Next.js build output directory
  • Contains compiled pages, static files, and cache
  • Regenerated on next build

When to use: Only if your project uses Next.js framework.

How to check if you use Next.js:

grep "next" package.json

If you see "next" in dependencies, you're using Next.js.

Storage freed: Typically 50MB-500MB.



Command 2.6: Remove Nuxt.js Build Cache

What this does: Removes Nuxt.js build output (if using Nuxt.js framework).

Command:

rm -rf .nuxt

Explanation:

  • .nuxt/ is Nuxt.js build output directory
  • Similar to Next.js but for Nuxt framework

When to use: Only if using Nuxt.js.

Storage freed: Typically 50MB-300MB.



Command 2.7: Remove General Build Directories

What this does: Removes common build output directories used by various frameworks.

Command:

rm -rf dist build .cache .turbo

Explanation:

  • dist/ - Distribution/build output (common in many projects)
  • build/ - Build output directory
  • .cache/ - Framework-specific caches
  • .turbo/ - Turborepo monorepo cache

Safety: These are all build outputs, safe to delete.

Expected output: No output means success.

Storage freed: Varies by project, typically 10MB-200MB.



Command 2.8: Remove Yarn Cache (If Using Yarn)

What this does: Removes Yarn package manager cache from the project.

Command:

rm -rf .yarn/cache .yarn/unplugged .yarn/build-state.yml

Explanation:

  • .yarn/cache/ - Yarn's local package cache
  • .yarn/unplugged/ - Unplugged packages
  • .yarn/build-state.yml - Build state cache

When to use: Only if your project uses Yarn (not npm).

How to check:

ls yarn.lock

If yarn.lock exists, you're using Yarn.

Storage freed: Typically 10MB-100MB.



Command 2.9: Clean npm Global Cache (System-Wide)

What this does: Cleans npm's global cache that affects all projects on your system.

Command:

npm cache clean --force

Explanation:

  • npm cache manages npm's cache
  • clean removes cached packages
  • --force skips confirmation prompt

What gets deleted:

  • Cached npm package tarballs
  • Metadata cache
  • Other npm cache files

Storage freed: Typically 500MB-2GB system-wide.

Location: Usually ~/.npm/ on macOS/Linux.

Safety: Safe - packages will be re-downloaded when needed.

Expected output:

npm cache cleaned


Command 2.10: Verify Node.js Cleanup

What this does: Checks if cleanup was successful.

Command:

ls -la | grep -E "node_modules|\.next|\.nuxt|dist|build"

Explanation:

  • Lists files and searches for common build directories
  • -E enables extended regex
  • Shows any remaining build directories

Expected output:

  • Empty output = Cleanup successful!
  • Directory names = Some build directories still exist.


Command 2.11: Restore Node.js Dependencies (After Cleanup)

What this does: Re-installs all npm packages after cleanup.

Command:

npm install

Explanation:

  • Reads package.json and package-lock.json
  • Downloads and installs all dependencies
  • Creates new node_modules/ folder

Expected output:

added 1234 packages, and audited 1234 packages in 45s

Time taken: 30 seconds to 5 minutes depending on number of packages.

Alternative (if using Yarn):

yarn install


Node.js Cleanup Summary

Commands to run in order:

  1. cd /path/to/node/project - Navigate to project
  2. du -sh node_modules - Check size (optional)
  3. rm -rf node_modules - Remove dependencies
  4. rm -rf .next - Remove Next.js cache (if applicable)
  5. rm -rf .nuxt - Remove Nuxt.js cache (if applicable)
  6. rm -rf dist build .cache .turbo - Remove build directories
  7. npm cache clean --force - Clean global cache (optional)
  8. npm install - Restore dependencies

Total storage typically freed: 100MB - 1GB+ per Node.js project



Part 3: Cleaning Android/Kotlin/Java Projects - Complete Command Guide

Android projects with Gradle build system can accumulate significant cache. Here's the complete cleanup process.

Command 3.1: Navigate to Your Android Project

What this does: Changes to your Android project directory.

Command:

cd /path/to/your/android/project

Example:

cd ~/Documents/code/my_android_app


Command 3.2: Verify You're in an Android Project

What this does: Confirms you're in an Android project.

Command:

ls build.gradle build.gradle.kts settings.gradle 2>/dev/null | head -1

Explanation:

  • Checks for Gradle build files
  • 2>/dev/null hides errors
  • head -1 shows only first match

Expected output: One of: build.gradle, build.gradle.kts, or settings.gradle



Command 3.3: Remove Project Build Directory

What this does: Removes the main build output directory.

Command:

rm -rf build

Explanation:

  • build/ contains all Gradle build outputs
  • Includes compiled classes, resources, APKs, etc.
  • Regenerated on next build

Storage freed: Typically 100MB-500MB.



Command 3.4: Remove Local Gradle Cache

What this does: Removes Gradle cache specific to this project.

Command:

rm -rf .gradle

Explanation:

  • .gradle/ contains project-specific Gradle cache
  • Includes build cache, dependency cache, etc.
  • Speeds up builds but safe to delete

Storage freed: Typically 50MB-200MB.



Command 3.5: Remove App Build Directory

What this does: Removes app module build outputs (for multi-module projects).

Command:

rm -rf app/build

Explanation:

  • app/build/ contains app-specific build artifacts
  • Only exists if you have an app/ module
  • Safe to delete

Storage freed: Typically 50MB-300MB.



Command 3.6: Remove All Build Directories (Comprehensive)

What this does: Finds and removes ALL build directories in the project.

Command:

find . -type d -name "build" -exec rm -rf {} +

Explanation: Same as Flutter - removes all directories named "build".

Expected output: No output means success.



Command 3.7: Clean IntelliJ IDEA Caches (If Using Android Studio)

What this does: Removes IDE cache files while preserving project settings.

Command:

rm -rf .idea/caches .idea/libraries

Explanation:

  • .idea/caches/ - IDE build and index caches
  • .idea/libraries/ - Cached library information
  • Preserves .idea/ directory and other IDE settings

Safety: Only removes caches, not IDE configuration.

Storage freed: Typically 10MB-100MB.



Command 3.8: Remove Kotlin Compiler Output

What this does: Removes Kotlin compiler output directory.

Command:

rm -rf out

Explanation:

  • out/ contains Kotlin compiler outputs
  • Only exists in some Kotlin projects
  • Safe to delete

Storage freed: Typically 10MB-50MB.



Command 3.9: Clean System-Wide Gradle Cache (Maximum Cleanup)

What this does: Removes Gradle cache for ALL projects on your system.

Command:

rm -rf ~/.gradle/caches

Explanation:

  • ~/.gradle/caches/ is Gradle's global cache directory
  • Contains cached dependencies for all projects
  • ~ is your home directory

What gets deleted:

  • Cached Gradle dependencies
  • Build cache
  • Wrapper distributions

Storage freed: Typically 2GB-10GB system-wide.

Warning: All projects will need to re-download dependencies on next build.

Expected output: No output means success.



Command 3.10: Clean Gradle Daemon

What this does: Removes Gradle daemon cache and stops running daemons.

Command:

rm -rf ~/.gradle/daemon

Explanation:

  • Gradle daemon runs in background to speed up builds
  • Cache can accumulate over time
  • Safe to delete - daemon will restart when needed

Storage freed: Typically 50MB-200MB.



Command 3.11: Verify Android Cleanup

What this does: Checks if cleanup was successful.

Command:

find . -type d \( -name "build" -o -name ".gradle" \) 2>/dev/null

Expected output:

  • Empty output = Cleanup successful!
  • Directory names = Some build directories still exist.


Android Cleanup Summary

Commands to run in order:

  1. cd /path/to/android/project - Navigate to project
  2. rm -rf build .gradle - Remove project build files
  3. rm -rf app/build - Remove app build (if applicable)
  4. rm -rf .idea/caches - Clean IDE cache (if applicable)
  5. rm -rf ~/.gradle/caches - Clean system Gradle cache (optional, affects all projects)
  6. Rebuild project - Gradle will re-download dependencies

Total storage typically freed: 500MB - 3GB per Android project (more with system cache cleanup)



Part 4: Cleaning iOS/Swift Projects - Complete Command Guide

iOS projects with Xcode and CocoaPods can consume significant storage. Here's how to clean them.

Command 4.1: Navigate to Your iOS Project

What this does: Changes to your iOS project directory.

Command:

cd /path/to/your/ios/project

Example:

cd ~/Documents/code/my_ios_app


Command 4.2: Verify You're in an iOS Project

What this does: Confirms you're in an iOS project.

Command:

ls *.xcodeproj *.xcworkspace Package.swift 2>/dev/null | head -1

Explanation:

  • Checks for Xcode project files or Swift Package Manager manifest
  • Shows first match found

Expected output: One of: .xcodeproj, .xcworkspace, or Package.swift



Command 4.3: Remove Swift Package Manager Build

What this does: Removes Swift Package Manager build artifacts.

Command:

rm -rf .build

Explanation:

  • .build/ contains Swift Package Manager build outputs
  • Only exists if using Swift Package Manager
  • Regenerated on next build

Storage freed: Typically 50MB-200MB.



Command 4.4: Remove CocoaPods Dependencies

What this does: Removes CocoaPods dependencies and lock file.

Command:

rm -rf Pods Podfile.lock

Explanation:

  • Pods/ contains all CocoaPods dependencies (can be 500MB-1GB)
  • Podfile.lock locks dependency versions
  • Regenerated with pod install

What gets deleted:

  • All CocoaPods framework files
  • Dependency source code
  • Lock file

What's preserved:

  • Podfile (dependency configuration)
  • ✅ All source code

Storage freed: Typically 500MB-1.5GB.



Command 4.5: Remove Xcode Build Products

What this does: Removes Xcode build output directory.

Command:

rm -rf build DerivedData

Explanation:

  • build/ contains Xcode build products
  • DerivedData/ contains build data and indexes
  • Both regenerated on next build

Storage freed: Typically 100MB-500MB per project.



Command 4.6: Remove Swift Package Manager Cache

What this does: Removes Swift Package Manager cache.

Command:

rm -rf .swiftpm

Explanation:

  • .swiftpm/ contains Swift Package Manager cache
  • Speeds up package resolution but safe to delete

Storage freed: Typically 10MB-50MB.



Command 4.7: Clean Xcode User Data (Optional)

What this does: Removes user-specific Xcode data while preserving project files.

Command:

find . -type d -name "xcuserdata" -exec rm -rf {} +

Explanation:

  • xcuserdata/ contains user-specific Xcode settings
  • Includes breakpoints, schemes, etc.
  • Safe to delete - Xcode will recreate

Storage freed: Typically 1MB-10MB.



Command 4.8: Clean System-Wide Xcode DerivedData (Maximum Cleanup)

What this does: Removes Xcode DerivedData for ALL projects on your system.

Command:

rm -rf ~/Library/Developer/Xcode/DerivedData

Explanation:

  • DerivedData/ contains build data for all Xcode projects
  • Includes indexes, build products, logs
  • ~/Library/Developer/Xcode/ is Xcode's system directory

What gets deleted:

  • Build data for all projects
  • Index files
  • Build logs
  • Intermediate build files

Storage freed: Typically 5GB-20GB system-wide.

Warning: All Xcode projects will need to rebuild indexes on next open.

Expected output: No output means success.



Command 4.9: Clean Xcode Archives (Old App Builds)

What this does: Removes old archived app builds.

Command:

rm -rf ~/Library/Developer/Xcode/Archives

Explanation:

  • Archives/ contains archived app builds for distribution
  • Old archives can accumulate over time
  • Safe to delete if you don't need old builds

Storage freed: Typically 1GB-10GB.

When to use: Only if you have old archives you don't need.



Command 4.10: Clean CocoaPods Cache (System-Wide)

What this does: Removes CocoaPods global cache.

Command:

rm -rf ~/Library/Caches/CocoaPods

Explanation:

  • CocoaPods caches downloaded pods globally
  • Can accumulate over time
  • Safe to delete - pods will be re-downloaded

Storage freed: Typically 100MB-1GB.



Command 4.11: Verify iOS Cleanup

What this does: Checks if cleanup was successful.

Command:

find . -type d \( -name "Pods" -o -name ".build" -o -name "build" -o -name "DerivedData" \) 2>/dev/null

Expected output:

  • Empty output = Cleanup successful!
  • Directory names = Some build directories still exist.


Command 4.12: Restore CocoaPods Dependencies (After Cleanup)

What this does: Re-installs CocoaPods dependencies after cleanup.

Command:

pod install

Explanation:

  • Reads Podfile
  • Downloads and installs all CocoaPods dependencies
  • Creates new Pods/ directory

Prerequisites: CocoaPods must be installed (sudo gem install cocoapods)

Expected output:

Analyzing dependencies
Downloading dependencies
Installing [PodName] (1.0.0)
Generating Pods project

Time taken: 1-5 minutes depending on number of pods.



iOS Cleanup Summary

Commands to run in order:

  1. cd /path/to/ios/project - Navigate to project
  2. rm -rf Pods Podfile.lock - Remove CocoaPods
  3. rm -rf .build build DerivedData - Remove build artifacts
  4. rm -rf ~/Library/Developer/Xcode/DerivedData - Clean system DerivedData (optional)
  5. rm -rf ~/Library/Developer/Xcode/Archives - Clean old archives (optional)
  6. pod install - Restore CocoaPods (if applicable)

Total storage typically freed: 500MB - 2GB per iOS project (20GB+ with system cleanup)



Part 5: System-Wide Cache Cleanup - Maximum Storage Recovery

Beyond individual projects, system-wide caches can consume significant storage. Here's how to clean them.

Command 5.1: Clean User Caches (macOS/Linux)

What this does: Removes all user application caches.

Command:

rm -rf ~/Library/Caches/*

Explanation:

  • ~/Library/Caches/ contains caches for all user applications
  • Includes browser caches, app caches, etc.
  • Safe to delete - apps will recreate caches

Storage freed: Typically 1GB-5GB.

Warning: Some apps may be slightly slower on first launch after cleanup.

Expected output: No output means success.



Command 5.2: Clean System Logs (macOS)

What this does: Removes system log files older than 7 days.

Command:

sudo find /private/var/log -type f -mtime +7 -delete

Explanation:

  • sudo requires administrator password
  • /private/var/log is system log directory
  • -mtime +7 finds files older than 7 days
  • -delete removes found files

Storage freed: Typically 100MB-1GB.

Safety: Only removes old logs, not recent ones.



Command 5.3: Clean User Logs

What this does: Removes user application log files.

Command:

rm -rf ~/Library/Logs/*

Explanation:

  • ~/Library/Logs/ contains logs for user applications
  • Safe to delete - logs are recreated as needed

Storage freed: Typically 50MB-500MB.



Command 5.4: Clean Homebrew Cache (macOS)

What this does: Removes Homebrew package manager cache and old versions.

Command:

brew cleanup --prune=all

Explanation:

  • brew is Homebrew package manager
  • cleanup removes old package versions
  • --prune=all removes all cached files

Prerequisites: Homebrew must be installed.

Storage freed: Typically 1GB-5GB.

Expected output:

Removing: /opt/homebrew/Cellar/package/old-version
...


Command 5.5: Clean Docker (If Using Docker)

What this does: Removes all unused Docker containers, images, and volumes.

Command:

docker system prune -a --volumes

Explanation:

  • docker system prune removes unused Docker resources
  • -a removes all unused images (not just dangling)
  • --volumes removes unused volumes

Prerequisites: Docker must be installed and running.

Storage freed: Typically 5GB-50GB+ depending on usage.

Warning: This removes ALL unused Docker resources. Make sure you don't need them.

Expected output:

WARNING! This will remove:
  - all stopped containers
  - all networks not used by at least one container
  - all images without at least one container associated to them
  - all build cache
  - all volumes not used by at least one container

Are you sure you want to continue? [y/N]

Type y to confirm.



Command 5.6: Clean npm Global Cache

What this does: Removes npm's global cache (same as Command 2.9, listed here for system cleanup).

Command:

npm cache clean --force

Storage freed: Typically 500MB-2GB.



Command 5.7: Clean Yarn Global Cache

What this does: Removes Yarn's global cache.

Command:

yarn cache clean

Explanation:

  • Cleans Yarn's global package cache
  • Similar to npm cache clean

Storage freed: Typically 500MB-2GB.



Command 5.8: Reset iOS Simulators (All Simulators)

What this does: Erases all iOS Simulator data, resetting them to factory state.

Command:

xcrun simctl erase all

Explanation:

  • xcrun simctl manages iOS Simulators
  • erase all resets all simulators
  • Simulators remain installed, but data is cleared

Storage freed: Typically 1GB-5GB.

Warning: All simulator apps and data will be deleted.

Expected output:

Erasing all available simulators...


Command 5.9: Reset Android Emulators (AVDs)

What this does: Resets Android Virtual Device data while keeping emulators installed.

Command:

for avd in ~/.android/avd/*.avd; do
    rm -rf "$avd/data" "$avd/snapshots" 2>/dev/null
    echo "Reset AVD: $(basename "$avd")"
done

Explanation:

  • Loops through all AVD directories
  • Removes data and snapshot directories
  • Keeps AVD configuration intact

Storage freed: Typically 1GB-5GB per AVD.

Expected output:

Reset AVD: Pixel_5_API_30.avd
Reset AVD: Nexus_5X_API_29.avd
...


System Cleanup Summary

Commands to run (choose based on what you use):

  1. rm -rf ~/Library/Caches/* - Clean user caches
  2. rm -rf ~/.gradle/caches - Clean Gradle cache (if using Android)
  3. rm -rf ~/Library/Developer/Xcode/DerivedData - Clean Xcode DerivedData (if using iOS)
  4. brew cleanup --prune=all - Clean Homebrew (if using Homebrew)
  5. docker system prune -a --volumes - Clean Docker (if using Docker)
  6. npm cache clean --force - Clean npm cache
  7. xcrun simctl erase all - Reset iOS Simulators (if using iOS)

Total storage typically freed: 10GB-50GB+ system-wide



Part 6: Finding and Cleaning All Projects at Once

Instead of cleaning projects one by one, here's how to find and clean all projects automatically.

Command 6.1: Find All Flutter Projects

What this does: Finds all Flutter projects in a directory tree.

Command:

find /path/to/search -name "pubspec.yaml" -type f

Explanation:

  • find searches directory tree
  • -name "pubspec.yaml" looks for Flutter config files
  • -type f limits to files only
  • Replace /path/to/search with your search directory

Example:

find ~/Documents -name "pubspec.yaml" -type f

Expected output:

/Users/yourname/Documents/code/project1/pubspec.yaml
/Users/yourname/Documents/code/project2/pubspec.yaml
...


Command 6.2: Clean All Flutter Projects

What this does: Finds and cleans all Flutter projects automatically.

Command:

find /path/to/search -name "pubspec.yaml" -type f -exec dirname {} \; | while read dir; do
    echo "Cleaning Flutter project: $dir"
    cd "$dir" && flutter clean 2>&1 | head -3
done

Explanation:

  • Finds all pubspec.yaml files
  • -exec dirname {} \; gets directory containing each file
  • Loops through each directory
  • Runs flutter clean in each

Expected output:

Cleaning Flutter project: /path/to/project1
Cleaning Xcode workspace...
Cleaning Flutter project: /path/to/project2
...


Command 6.3: Find All Node.js Projects

What this does: Finds all Node.js projects.

Command:

find /path/to/search -name "package.json" -type f -not -path "*/node_modules/*"

Explanation:

  • Finds package.json files
  • -not -path "*/node_modules/*" excludes node_modules folders

Expected output: List of all Node.js project paths.



Command 6.4: Clean All Node.js Projects

What this does: Removes node_modules from all Node.js projects.

Command:

find /path/to/search -name "package.json" -type f -not -path "*/node_modules/*" -exec dirname {} \; | while read dir; do
    echo "Cleaning Node.js project: $dir"
    cd "$dir" && rm -rf node_modules .next .nuxt dist build 2>/dev/null
    echo "✅ Cleaned: $dir"
done

Explanation:

  • Finds all Node.js projects
  • Removes common build directories from each
  • Shows progress for each project

Expected output:

Cleaning Node.js project: /path/to/project1
✅ Cleaned: /path/to/project1
Cleaning Node.js project: /path/to/project2
✅ Cleaned: /path/to/project2
...


Command 6.5: Find All Android Projects

What this does: Finds all Android projects.

Command:

find /path/to/search \( -name "build.gradle" -o -name "build.gradle.kts" -o -name "settings.gradle" \) -type f | head -20

Explanation:

  • Finds Gradle build files
  • -o means OR (any of these files)
  • head -20 limits to first 20 results


Command 6.6: Clean All Android Projects

What this does: Cleans all Android projects.

Command:

find /path/to/search \( -name "build.gradle" -o -name "settings.gradle" \) -type f -exec dirname {} \; | sort -u | while read dir; do
    echo "Cleaning Android project: $dir"
    cd "$dir" && rm -rf build .gradle 2>/dev/null
    find . -type d -name "build" -exec rm -rf {} + 2>/dev/null
    echo "✅ Cleaned: $dir"
done

Explanation:

  • Finds Android projects
  • sort -u removes duplicates
  • Cleans each project


Command 6.7: Find All iOS Projects

What this does: Finds all iOS projects.

Command:

find /path/to/search \( -name "*.xcodeproj" -o -name "*.xcworkspace" -o -name "Package.swift" \) -type f | head -20


Command 6.8: Clean All iOS Projects

What this does: Cleans all iOS projects.

Command:

find /path/to/search -name "Podfile" -type f -exec dirname {} \; | while read dir; do
    echo "Cleaning iOS project: $dir"
    cd "$dir" && rm -rf Pods Podfile.lock .build build DerivedData 2>/dev/null
    echo "✅ Cleaned: $dir"
done


Bulk Cleanup Summary

To clean all projects of a specific type:

  1. Use the "Find" commands to locate projects
  2. Use the "Clean All" commands to clean them
  3. Replace /path/to/search with your actual directory (e.g., ~/Documents)

Example - Clean everything in Documents:

# Clean all Flutter projects
find ~/Documents -name "pubspec.yaml" -type f -exec dirname {} \; | while read dir; do
    cd "$dir" && flutter clean 2>&1 | head -1
done

# Clean all Node.js projects
find ~/Documents -name "package.json" -type f -not -path "*/node_modules/*" -exec dirname {} \; | while read dir; do
    cd "$dir" && rm -rf node_modules .next .nuxt dist build 2>/dev/null
done


Safety Guidelines: What's Safe to Delete

✅ Always Safe to Delete

  • Build directories (build/, dist/, .next/, etc.)
  • Cache directories (.dart_tool/, .gradle/, .cache/, etc.)
  • Dependencies (node_modules/, Pods/, etc.)
  • Generated files (.flutter-plugins, lock files, etc.)
  • IDE caches (.idea/caches/, DerivedData, etc.)

⚠️ Be Careful With

  • Source code directories (lib/, src/, app/, etc.) - Never delete!
  • Configuration files (package.json, pubspec.yaml, build.gradle, etc.) - Never delete!
  • Git directories (.git/) - Never delete!
  • Assets and resources - Only delete if you're sure they're not needed

❌ Never Delete

  • Source code files (.dart, .js, .kt, .swift, etc.)
  • Project configuration (pubspec.yaml, package.json, etc.)
  • Version control (.git/ directory)
  • Documentation (README files, etc.)
  • Assets (images, fonts, etc.)

Safety Checklist

Before running cleanup commands:

  • Commit your work to Git
  • Verify you're in the correct directory
  • Understand what the command does
  • Have a backup (Git commit counts)
  • Test the project builds after cleanup


Troubleshooting: Common Issues and Solutions

Issue 1: "Permission Denied" Error

Error:

rm: cannot remove 'build': Permission denied

Solution:

sudo rm -rf build

Explanation: Some files may require administrator privileges. Use sudo (enter your password when prompted).

Better solution: Fix permissions:

sudo chown -R $USER:$USER /path/to/project


Issue 2: "Command Not Found" for Flutter/npm

Error:

flutter: command not found

Solution: Install the required tool or use manual cleanup commands instead.

For Flutter:

# Add Flutter to PATH (add to ~/.zshrc or ~/.bashrc)
export PATH="$PATH:/path/to/flutter/bin"
source ~/.zshrc  # or ~/.bashrc

For npm:
Install Node.js from nodejs.org



Issue 3: Project Won't Build After Cleanup

Symptoms:

  • Flutter: "Package not found"
  • Node.js: "Module not found"
  • Android: "Gradle sync failed"

Solution: Restore dependencies:

# Flutter
flutter pub get

# Node.js
npm install

# Android (automatic on next build)
# iOS
pod install


Issue 4: "No Space Left on Device"

Error:

rm: cannot remove: No space left on device

Solution:

  1. Clean system caches first (see Part 5)
  2. Delete large files manually
  3. Empty Trash
  4. Then run project cleanup


Issue 5: Script Runs But Doesn't Find Projects

Possible causes:

  • Projects are too deeply nested
  • Projects don't have detection files
  • Wrong search path

Solution:

  • Run from a directory closer to projects
  • Verify projects have pubspec.yaml, package.json, etc.
  • Use absolute paths instead of relative


Best Practices: Maintaining a Clean Development Environment

1. Regular Cleanup Schedule

Recommended frequency:

  • Active projects: Weekly
  • All projects: Monthly
  • Before major updates: Clean before upgrading Flutter, Node.js, etc.

2. Clean Before Committing

# Clean project
flutter clean  # or equivalent

# Commit cleaned state
git add .
git commit -m "Clean build artifacts"

3. Use .gitignore

Ensure build directories are in .gitignore:

# Flutter
build/
.dart_tool/

# Node.js
node_modules/
.next/
dist/

# Android
build/
.gradle/

# iOS
Pods/
DerivedData/

4. Monitor Storage

Check storage usage regularly:

# Check project size
du -sh /path/to/project

# Find large directories
du -h /path/to/project | sort -h | tail -10

5. Clean System Caches Monthly

Run system-wide cleanup monthly:

# Clean user caches
rm -rf ~/Library/Caches/*

# Clean Gradle (if using Android)
rm -rf ~/.gradle/caches

# Clean Xcode (if using iOS)
rm -rf ~/Library/Developer/Xcode/DerivedData

6. Keep Dependencies Updated

Regularly update and remove unused dependencies:

# Flutter
flutter pub upgrade

# Node.js
npm update
npm audit fix


FAQ: Your Questions Answered

Q1: Will I lose my work if I run these commands?

A: No! These commands only delete build artifacts, caches, and dependencies. Your source code, configuration files, and Git history are never touched. Always commit your work first as a safety measure.

Q2: How much storage will I actually free up?

A: It depends on:

  • Number of projects (typically 10-50GB+ for developers with multiple projects)
  • Project types (Flutter/Android projects tend to be larger)
  • Time since last cleanup (longer = more accumulation)

Typical results:

  • Single Flutter project: 500MB-2GB
  • Single Node.js project: 100MB-1GB
  • 20 mixed projects: 10-50GB
  • With system caches: 50-100GB+

Q3: How often should I clean my projects?

A:

  • Active projects: Weekly or before major builds
  • All projects: Monthly
  • Before updates: Clean before upgrading tools or dependencies

Q4: Can I undo the cleanup?

A: You can't undo the deletion, but you can regenerate everything:

  • Flutter: Run flutter pub get and rebuild
  • Node.js: Run npm install
  • Android: Gradle re-downloads on next build
  • iOS: Run pod install if using CocoaPods

Q5: Will cleanup make my projects build slower?

A: The first build after cleanup may be slightly slower as dependencies are re-downloaded. Subsequent builds will be normal speed. The trade-off is worth it for the storage freed.

Q6: Do these commands work on Windows?

A: Most commands work on Windows with:

  • Git Bash (recommended)
  • WSL (Windows Subsystem for Linux)
  • PowerShell (with minor syntax adjustments)

For Windows-specific paths, use %USERPROFILE% instead of ~.

Q7: What if I have projects in multiple locations?

A: Run the cleanup commands for each location, or use the bulk cleanup commands (Part 6) with a parent directory that contains all your projects.

Q8: Can I exclude certain projects from cleanup?

A: Yes! Either:

  1. Move projects you want to keep elsewhere before running bulk cleanup
  2. Run cleanup on specific subdirectories only
  3. Manually clean projects one by one

Q9: Is it safe to delete node_modules?

A: Yes! node_modules can always be regenerated with npm install. It's one of the safest things to delete. Many developers delete it regularly.

Q10: What about .git directories?

A: These commands never touch .git/ directories. Your Git history is completely safe. The commands are designed to only remove build artifacts and caches.



Conclusion: Reclaim Your Storage Today

What You've Learned

You now have a complete command reference for cleaning:

  • ✅ Flutter/Dart projects
  • ✅ Node.js/npm projects
  • ✅ Android/Kotlin/Java projects
  • ✅ iOS/Swift projects
  • ✅ System-wide caches

Expected Results

After following this guide, you should free up:

  • 10-50GB+ for typical developers
  • 50-100GB+ with system-wide cleanup
  • Faster project searches (fewer files to index)
  • Cleaner development environment

Next Steps

  1. Start with one project type - Pick Flutter, Node.js, Android, or iOS
  2. Run the commands step by step - Follow the guide for your project type
  3. Verify everything works - Rebuild your project to ensure it still works
  4. Expand to all projects - Use bulk cleanup commands for all projects
  5. Clean system caches - Run system-wide cleanup for maximum storage recovery
  6. Schedule regular cleanup - Set a monthly reminder

Final Tips

  • Always commit to Git first - Safety net before cleanup
  • Start small - Clean one project first to get comfortable
  • Verify after cleanup - Make sure projects still build
  • Regular maintenance - Clean monthly to prevent accumulation

Share Your Results

We'd love to hear how much storage you freed! This guide is designed to be beginner-friendly while providing comprehensive coverage for all project types.



Last Updated: 2025
Compatibility: macOS, Linux, Windows (Git Bash/WSL)
Difficulty: Beginner to Intermediate
Time Required: 15-60 minutes depending on number of projects



This guide provides safe cleanup commands for development projects. Always commit your work to Git before running cleanup commands. The authors are not responsible for any data loss, though these commands are designed to be safe and only remove build artifacts.

0 Comments

⚠️

Ad Blocker Detected

We noticed you are using an ad blocker. We rely on ads to keep this website free for everyone. Please disable your ad blocker or whitelist our site to continue.