Building a React Native app with Rork should be smooth, but one misstep and you're staring at cryptic error messages. Metro Bundler won't start, Gradle fails mysteriously, Xcode complains about code signing, or the app crashes on startup for no obvious reason.
This guide provides a systematic diagnosis flowchart and step-by-step remedies for every category of React Native build failure. By the end, you'll know exactly what went wrong and how to fix it—often in minutes, not hours.
Diagnostic Flowchart
When you hit a build error, follow this decision tree to identify the root cause.
1. npm start fails? → Metro Bundler issue
├─ "Cannot find module" → Missing dependency
├─ "EADDRINUSE" → Port already in use
├─ "ENOSPC" → Disk full
└─ "Syntax error" → JavaScript typo
2. npm run android fails? → Gradle/Android build
├─ "FAILURE: Build failed" → Gradle config
├─ "Could not find" → Missing library
└─ "minSdkVersion" → SDK mismatch
3. npm run ios fails? → Xcode/iOS build
├─ "No such module" → CocoaPods not installed
├─ "Multiple commands produce" → Build collision
└─ "Code signing" → Certificate missing
4. App builds but doesn't launch? → Runtime error
├─ "Red Screen" → JavaScript exception
└─ "Native crash" → Native code issue
Error 1: Metro Bundler Won't Start
Symptoms
npm start
Error: Failed to load /path/to/metro.config.js
Cannot find module 'metro'
Root Causes
node_modulesis missing or corrupted- Metro dependencies not fully installed
package-lock.jsonis out of sync withpackage.json
Solution
# Step 1: Nuclear option—delete everything
rm -rf node_modules package-lock.json
# Step 2: Fresh install
npm cache clean --force
npm install
# Step 3: If using Expo
expo prebuild --clean
# Step 4: Clear Metro temp files
rm -rf /tmp/metro-*
rm -rf $TMPDIR/metro-* # macOS
# Step 5: Start again
npm startError 2: "EADDRINUSE: Address Already in Use"
Symptoms
Starting Metro Bundler
> listening on port 8081
Error: listen EADDRINUSE: address already in use :::8081
Root Cause
Another process owns port 8081 (likely a previous Metro instance that didn't shut down cleanly).
Solution
# Identify the process using port 8081
lsof -i :8081
# Example output:
# COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
# node 12345 user 25u IPv6 0x12345678 0t0 TCP *:8081 (LISTEN)
# Kill the process
kill -9 12345
# Or use a different port
npm start -- --port 8082Error 3: "Cannot Find Module"
Symptoms
Error: Cannot find module '@react-navigation/native'
Cannot find module 'axios'
Root Causes
- Module not listed in
package.json - Download failed during
npm install - Rork-generated code references a module you haven't installed
Solution
# Install the missing module
npm install @react-navigation/native axios
# Verify package.json contains it
cat package.json | grep "dependencies\|devDependencies" -A 20
# Clean install from package.json
npm ci
# For native-linked modules, sometimes you need
npx react-native linkError 4: Android Gradle Build Failure
Symptom A: "Could not resolve all dependencies"
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not find com.facebook.react:react-native:0.73.0
Root Causes
- Android SDK not installed or configured
- Gradle version mismatch with React Native version
- Native module dependencies incomplete
Solution
# Step 1: Verify Android SDK is installed
echo $ANDROID_HOME
# If empty, install it:
# macOS: Use Android Studio's SDK Manager
# Or manually:
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
# Step 2: Check and fix gradle.properties
cat android/gradle.propertiesRecommended gradle.properties:
android.useAndroidX=true
android.enableJetifier=true
org.gradle.jvmargs=-Xmx2g -XX:MaxPermSize=512m
org.gradle.parallel=true
# Match your React Native version
REACT_NATIVE_VERSION=0.73.0
ANDROID_SDK_VERSION=34# Step 3: Clear Gradle cache
rm -rf android/.gradle
# Step 4: Rebuild
npm run androidSymptom B: "Target API Level Mismatch"
The minSdkVersion should be minimum 21
Solution
Edit android/build.gradle:
buildscript {
ext {
buildToolsVersion = "34.0.0"
minSdkVersion = 21
compileSdkVersion = 34
targetSdkVersion = 34
}
}Error 5: Xcode iOS Build Failure
Symptom A: "No such module 'FBReactNativeSpec'"
Build failed: No such module 'FBReactNativeSpec'
Root Cause
CocoaPods dependencies weren't fully installed for iOS.
Solution
# Step 1: Clean Pods
rm -rf ios/Pods ios/Podfile.lock
# Step 2: Reinstall
cd ios
pod install --repo-update
cd ..
# Step 3: Clear Xcode build cache
xcodebuild clean -workspace ios/{ProjectName}.xcworkspace \
-scheme {ProjectName}
# Step 4: Rebuild
npm run iosSymptom B: "Multiple Commands Produce"
error: Multiple commands produce 'Build/Intermediates.noindex/...'
Root Cause
Build configuration contains duplicate file references.
Solution
# Check the build config
grep -n "path.*\.m\|path.*\.swift" ios/{ProjectName}.xcodeproj/project.pbxproj
# Or in Xcode:
# Build Phases → Compile Sources (remove duplicates)Symptom C: "Code Signing" Error
Code Signing Error: "iPhone Developer" identity does not exist
Root Cause
Apple developer certificate not installed or accessible.
Solution
# List installed certificates
security find-identity -v -p codesigning
# Import your certificate in Xcode
# Xcode Preferences → Accounts → Apple ID (sign in)
# Then in Xcode:
# Select Target → Signing & Capabilities → Select TeamError 6: Expo Configuration Mismatch
Symptoms
Error: Cannot find module 'expo'
Error: Expo version mismatch
Root Causes
expo-clinot installed globally- Project's Expo version differs from installed version
app.jsonmalformed or incomplete
Solution
# Step 1: Install Expo CLI globally
npm install -g expo-cli
# Step 2: Update project Expo to latest
npm install expo@latest
# Step 3: Verify app.json structure
cat app.jsonWell-formed app.json for Rork:
{
"expo": {
"name": "My App",
"slug": "my-app",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"ios": {
"supportsTabletMode": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png"
}
}
}
}# Step 4: Restart
npm startError 7: JavaScript Runtime Error (Red Screen)
Symptoms
ReferenceError: Can't find variable: __dirname
ReferenceError: Can't find variable: process
Or the app launches, then immediately shows a red error screen.
Root Causes
- Using Node.js globals (
__dirname,__filename,process) - Using server-only modules (
fs,path) - Typo in module import
Solution
// ❌ WRONG: Node.js only
const path = require('path');
const filePath = __dirname + '/data.json';
// ✅ RIGHT: React Native compatible
import { getDocumentAsync } from 'expo-file-system';
getDocumentAsync().then(uri => {
// Work with file
});Also verify android/gradle.properties:
org.gradle.jvmargs=-Xmx2g -XX:+UseG1GC -XX:MaxGCPauseMillis=200Error 8: Native Module Linking Failure
Symptoms
error: No matching constructor for initialization of 'java.lang.Exception'
Or iOS: "Bridging Header not found"
Root Cause
Rork-generated native code (Swift/Kotlin) doesn't match the project's build configuration.
Solution
# Re-run automatic linking
npx react-native link
# Verify iOS configuration
ls -la ios/Podfile
cat ios/Podfile | grep post_installIf problems persist:
cd ios
pod deintegrate
pod install --repo-update
cd ..Common Questions (FAQ)
Q: Build succeeds, but the app crashes immediately on launch.
A: Usually a native initialization failure (often permission-related).
# Get verbose output
npm run ios -- --verbose
npm run android -- --verbose
# Check Android logs
adb logcat | grep FATALQ: I keep getting "Cannot find module" even after npm install.
A: Partial installation. Use npm ci instead of npm install:
npm ci # Installs exact versions from package-lock.jsonQ: My iOS and Android use different library versions.
A: Lock the React Native version explicitly:
npm install react-native@0.73.0
rm -rf ios/Pods android/.gradle
npm installQ: Can I avoid local build errors by using EAS Build?
A: Yes. EAS Build (Expo's cloud service) eliminates local environment issues:
npm install -g eas-cli
eas build --platform ios
eas build --platform androidQ: Should I report Rork-generated build errors to Rork?
A: Yes, with this info:
- React Native version
- Node / npm version
- Full error message and stack trace
- Your Rork prompt (what you asked it to build)
Debugging Best Practices
- Read the entire error message — not just the first line
- Monitor Metro's output —
npm startconsole often has clues - Suspect cache corruption —
node_modules,Pods,.gradleare common culprits - Unify versions — ensure React Native, Expo, and Node.js are compatible
- Document your environment — create
.env.examplewith required variables - Use EAS Build when stuck — cloud builds bypass local configuration issues
- Verbose mode is your friend — add
--verboseto any command for more info
Looking back Troubleshooting Path
- Clear all caches (
node_modules,Pods,.gradle) - Reinstall dependencies (
npm ci) - Verify native configs (
gradle.properties,Podfile) - Check versions (React Native, Expo, Node.js)
- Enable verbose logging to spot the real issue
- Consider EAS Build if local environment is the bottleneck
For errors not covered here, check the Rork troubleshooting FAQ and React Native official docs.