Luis  Lança
Luis Lança

Reputation: 89

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

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

Upvotes: 8

Views: 13779

Answers (9)

Jay Singh
Jay Singh

Reputation: 206

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

Upvotes: 0

buteninvania
buteninvania

Reputation: 11

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

Upvotes: 0

Nict
Nict

Reputation: 3098

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

Upvotes: 1

Sudhanshu Sharma
Sudhanshu Sharma

Reputation: 1

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.

Upvotes: 0

Jason Jin
Jason Jin

Reputation: 1849

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

Upvotes: 4

Alish Giri
Alish Giri

Reputation: 2238

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.

Upvotes: 0

Jay
Jay

Reputation: 919

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.

Upvotes: 6

user13621789
user13621789

Reputation:

  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-*

Upvotes: 2

orta
orta

Reputation: 4285

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.

Upvotes: 0

Related Questions