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/.gradle
Get 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:

FolderA 15.1 GB projectA 5.3 GB projectComes back with
node_modules7.4 GB2.4 GBnpm ci (or yarn, pnpm, bun)
android/app/build5.6 GB841 MBthe next Android build
ios/Pods1.1 GB2.0 GBcd ios && bundle exec pod install
android/app/.cxx943 MBnonethe next Android build
android/.gradle38 MB35 MBthe next Gradle run
ios/build1 MB0.6 MBthe 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

  1. npm ci (or yarn install, pnpm install, bun install, matching the lockfile).
  2. cd ios && bundle exec pod install. Use plain pod install if the project has no Gemfile.
  3. npx react-native run-ios / run-android, or npx expo run:ios / run:android for Expo.

Don't delete

  • ios/Podfile, ios/Podfile.lock, Gemfile.lock and your lockfile: they pin the versions you reinstall.
  • android/build if your repository commits it (rare, but it happens): check with git ls-files android/build | head.
  • vendor/bundle is 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.