ERROR: main.jsbundle does not exist - React Native 0.60.4
Asked Answered
B

9

7

I'm trying to publish my first React Native app in App store and when I'll build in Xcode:
Product > Archive
appears some error, but i already have main.jsbundle

main.jsbundle does not exist. This must be a bug with

  • echo 'React Native

Screen Error:

Screen Error

Beall answered 26/8, 2019 at 19:54 Comment(0)
R
6

You can generate a new main.jsbundle using this command.

react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios

Run this command in your project directory.

Ries answered 17/7, 2020 at 10:42 Comment(0)
T
4

In my case, I was able to fix the issue by removing main.jsbundle from Bundle Resources.

  • Open react native project in xcode
  • Check if Copy Bundle Resources build phase contains main.jsbundle
  • If it contains, remove it and build again

enter image description here

Tahitian answered 4/8, 2020 at 21:36 Comment(2)
Hmm... What worked for me was adding main.jsbundle to Bundle Resources. I did this after following @Jay's suggestion and running react-native bundle.Burglarious
This felt wrong, so I went back and deleted it. My original problem happened when running Archive, and it still works. FWIW, I installed watchman for another error, so that could be it? Order of operations: 1. Run archive, archive fails, 2. Add main.jsbundle to Bundle Resources, archive succeeds, 3. Feel weird about it and delete main.jsbundle from Bundle Resources, 4. Find totally unrelated error building Android and install watchman, 5. Archive again, archive succeeds. Conclusion: original error was either due to missing watchman installation, or will forever remain a mystery.Burglarious
B
2
  1. Clear watchman watches:
watchman watch-del-all
  1. Delete node_modules:
rm -rf node_modules and run yarn install
  1. Reset Metro's cache:
yarn start --reset-cache
  1. Remove the cache:
rm -rf /tmp/metro-*
Bruis answered 17/7, 2020 at 6:37 Comment(0)
F
0

In Xcode, you should be able to find the main.jsbundle inside the Xcode project sidebar.

Xcode with main.jsbundle

  • If it isn't there, then you should drag the main.jsbundle into your Xcode project (in the default template app you can find it at ios/main.jsbundle)

  • If it is in there, but red - then you need to build a copy of the main.jsbundle which you can do via react-native bundle (and some additional args which you can look up.

Fishmonger answered 26/8, 2019 at 20:4 Comment(1)
I already have main.jsbundle, but when i run react-native bundle --dev false --entry-file index.js --bundle-output ios/main.jsbundle --platform ios doesn't works :/, appears another error: error index.js: [BABEL] /Users/luislanca/Desktop/name_folder/my_project/index.js: .rootPathSuffix is not a valid Plugin propertyJuliannajulianne
C
0

I was getting the error because of a bug in the code, instead of using simulator I was using Xcode to install a release build to my device which led to this error.

To fix this, run the app on the simulator make sure it builds and runs properly and then install it on your device.

Celeski answered 29/7, 2020 at 5:3 Comment(0)
T
0

Try this instead

  1. Go to Xcode
  2. Go to targets
  3. Select Build phases from the top
  4. Just remove main.jsbundle lib from Copy Bundle Resources in build phase
  5. re-run again.
Toggery answered 10/6, 2022 at 7:51 Comment(0)
S
0

For me it was a path-related issue (React Native v0.61).

To solve this issue on Apple Silicon Mac (M2), under build phase for Bundle React Native code and images:

export PATH=/opt/homebrew/bin:$PATH
export NODE_BINARY=node
../node_modules/react-native/scripts/react-native-xcode.sh
Squid answered 13/9, 2023 at 12:18 Comment(0)
L
0

Nict thank you - it helped me! After switching from Intel to m1, the compilation of the application for the Release build failed, namely the error "main.jsbundle does not exist. this must be a bug with". This helped me:

export PATH=/opt/homebrew/bin:$PATH
cd $PROJECT_DIR/..
export NODE_BINARY=node
./node_modules/react-native/scripts/react-native-xcode.sh

enter image description here

Lovelovebird answered 7/2, 2024 at 9:32 Comment(0)
K
0

Refresh main.jsbundle with these command

Android build code refresh:=> npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

rm -rf ./android/app/src/main/res/drawable-* rm -rf ./android/app/src/main/res/raw

iOS code Refresh : => npx react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios

Knapp answered 24/6, 2024 at 4:48 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.