'Bundler does not load automatically (No bundle URL present error)
After updating my React Native app to the latest version up to date (0.60.4), launching my app using react-native run-ios would result in my application starting without a Metro Bundler.
The application would then display the following error:

In order for my application to function properly, I need to start the Metro Bundler using npm start and then run react-native run-ios.
Although this is a workaround, previously I did not have this issue and simply running react-native run-ios would start the Metro Bundler automatically. How can I resolve this?
EDIT: My NSAppTransportSecurity from Info.plist:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
Solution 1:[1]
I guess this issue is common when upgrading existing projects to React Native v0.60.+.
For anyone encountering this issue on Mac:
- Open
Xcodeand locateBuild Phasesunder your project. - Tap on
Editor->Add Build Phase->Add Run Script Build Phase.
- Tap on the newly generated
Run Scripton the bottom ofBuild Phasestab. - Paste the following code:
export RCT_METRO_PORT="${RCT_METRO_PORT:=8081}"
echo "export RCT_METRO_PORT=${RCT_METRO_PORT}" > "${SRCROOT}/../node_modules/react-native/scripts/.packager.env"
if [ -z "${RCT_NO_LAUNCH_PACKAGER+xxx}" ] ; then
if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then
if ! curl -s "http://localhost:${RCT_METRO_PORT}/status" | grep -q "packager-status:running" ; then
echo "Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly"
exit 2
fi
else
open "$SRCROOT/../node_modules/react-native/scripts/launchPackager.command" || echo "Can't start packager automatically"
fi
fi
- Launch your project through
Xcode.Metro Bundlershould now automatically start. - After saving your changes, the next time you run
react-native run-iosin Terminal,Metro Bundlerwill automatically start and theNo bundle URL presenterror will no longer persist.
Solution 2:[2]
Follow this steps. I have also faced this issue and this was solved by :
- Update your react native cli to the latest version.
- If using androidX then please use jetifier and npx.
- Update your package JSON in which development dependencies look like this
"devDependencies": {
"@babel/core": "^7.4.3",
"@babel/runtime": "^7.4.3",
"babel-jest": "^24.7.1",
"jest": "^24.7.1",
"metro-react-native-babel-preset": "^0.53.1",
"react-test-renderer": "16.8.3"
},
There is a walk around to start the metro bundler.
Use : npm start --reset cache This will start your metro bundler.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | John Doe |
| Solution 2 | get_php_workin |
