guide
Free up space from old React Native projects (node_modules, Pods, Android builds)
Quick answer
In the project folder, everything below is rebuilt by the next install or build:
rm -rf node_modules ios/Pods ios/build android/app/build android/app/.cxx android/build android/.gradleGet it back with npm ci (or your lockfile's tool), then cd ios && bundle exec pod install, then build as usual. Expo projects: npx expo run:ios / npx expo run:android.Where the space goes
From two real projects on the Mac Sweep was built on:
| Folder | A 15.1 GB project | A 5.3 GB project | Comes back with |
|---|---|---|---|
node_modules | 7.4 GB | 2.4 GB | npm ci (or yarn, pnpm, bun) |
android/app/build | 5.6 GB | 841 MB | the next Android build |
ios/Pods | 1.1 GB | 2.0 GB | cd ios && bundle exec pod install |
android/app/.cxx | 943 MB | none | the next Android build |
android/.gradle | 38 MB | 35 MB | the next Gradle run |
ios/build | 1 MB | 0.6 MB | the next iOS build |
Clean one project
cd ~/Projects/old-rn-app
rm -rf node_modules ios/Pods ios/build android/app/build android/app/.cxx android/build android/.gradle
./gradlew clean (in android/) only removes build outputs, and needs node_modules to still be there, so deleting the folders directly is simpler for a project you're putting away.
Bring it back
npm ci(oryarn install,pnpm install,bun install, matching the lockfile).cd ios && bundle exec pod install. Use plainpod installif the project has noGemfile.npx react-native run-ios/run-android, ornpx expo run:ios/run:androidfor Expo.
Don't delete
ios/Podfile,ios/Podfile.lock,Gemfile.lockand your lockfile: they pin the versions you reinstall.android/buildif your repository commits it (rare, but it happens): check withgit ls-files android/build | head.vendor/bundleis safe (Bundler reinstalls it), but only if it is not committed.
Shared caches outside the project
~/.gradle/caches (14 GB on our Mac) and the CocoaPods cache in ~/Library/Caches/CocoaPods serve all projects. pod cache clean --all empties the CocoaPods one.
Questions
Is it safe to delete ios/Pods?
Yes. pod install recreates it from Podfile.lock. Keep the Podfile and Podfile.lock.
Is android/app/build safe to delete?
Yes, it is the output of the Android build. The next build recreates it, so expect that first build to be slower.
What is android/app/.cxx?
The native (CMake/NDK) build cache that React Native's new architecture creates. It is safe to delete and is rebuilt on the next Android build.
Do I need bundle exec pod install or just pod install?
If the project has a Gemfile (most recent React Native templates do), use bundle exec pod install so the pinned CocoaPods version is used.