React Native项目卡Loading dependency graph及无index.android.js问题求助
Hey there, let’s tackle your React Native issues step by step—they’re tied to how create-react-native-app (CRNA) projects are structured, so let’s start with the missing index.android.js confusion first.
First: Why you don’t see index.android.js in your Android folder
When you create a project with create-react-native-app, you’re setting up an Expo-managed workflow project. In this setup, all the native code (including files like index.android.js) is handled and hosted by Expo behind the scenes—you won’t see these native files in your project root by default.
You only get access to the android folder and its native entry files if you convert the project to a bare workflow (where you manage native code yourself). This is only necessary if you need to add custom native modules or modify core native behavior—for most use cases, the Expo-managed workflow works perfectly fine without touching native code.
Fixing the "Loading dependency graph" hang issue
That stuck loading screen is almost always related to caching, dependency conflicts, network issues, or port conflicts. Let’s work through the most common fixes in order:
Reset the Metro bundler cache
Metro (React Native’s bundler) often gets tripped up by stale cache. Run this in your project root to clear it:# If you're using Expo CLI expo start -c # Or for vanilla React Native npx react-native start --reset-cacheThen try restarting your project.
Reinstall your dependencies
Corrupted or incompletenode_modulescan cause bundler hangs. Wipe them clean and reinstall:# Delete node_modules and lock files rm -rf node_modules package-lock.json yarn.lock # Reinstall (use yarn if that's your package manager) npm installCheck network/proxy settings
Metro needs to fetch some runtime dependencies, and a misconfigured proxy can block this. Verify and reset your npm proxy settings if needed:# Check current proxy config npm config get proxy npm config get https-proxy # Clear proxies if they're unnecessary npm config delete proxy npm config delete https-proxyAlso, try disabling any VPN or firewall temporarily to rule out network blocks.
Check for port conflicts
Metro uses port 8081 by default. If another app is using this port, the bundler will get stuck. Find and kill the process using the port:# macOS/Linux lsof -i :8081 | grep LISTEN | awk '{print $2}' | xargs kill -9 # Windows (PowerShell) Stop-Process -Id (Get-NetTCPConnection -LocalPort 8081).OwningProcess -ForceUpdate or downgrade Expo/CRNA tools
Sometimes version bugs cause bundler issues. Try updating Expo CLI to the latest stable version:npm install -g expo-cliIf the latest version is problematic, try a known-stable older version (e.g.,
expo-cli@4.12.10—adjust based on recent stable releases).
If you need access to native Android code
If you must modify native Android files (like adding a custom SDK), convert your project to a bare workflow with:
expo prebuild
This will generate the android and ios folders, including index.android.js and other native configuration files. Just note that this means you’ll have to maintain native code yourself going forward.
内容的提问来源于stack exchange,提问作者aasifghanchi

