Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

main.jsbundle does not exist #32108

Closed
taduyde opened this issue Aug 28, 2021 · 36 comments
Closed

main.jsbundle does not exist #32108

taduyde opened this issue Aug 28, 2021 · 36 comments
Labels
Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@taduyde
Copy link

taduyde commented Aug 28, 2021

Please provide all the information requested. Issues that do not follow this format are likely to stall.

Description

  • Use xcode to archive the new build,
  • Xcode throw the error
  • echo 'error: File /Users/robert/Library/Developer/Xcode/DerivedData/Kolbev-bphgvwixleedtdevmalrlelxeekn/Build/Intermediates.noindex/ArchiveIntermediates/Kolbev/BuildProductsPath/Release-iphoneos/Kolbev.app/main.jsbundle does not exist. This must be a bug with'
    error: File /Users/robert/Library/Developer/Xcode/DerivedData/Kolbev-bphgvwixleedtdevmalrlelxeekn/Build/Intermediates.noindex/ArchiveIntermediates/Kolbev/BuildProductsPath/Release-iphoneos/Kolbev.app/main.jsbundle does not exist. This must be a bug with
  • echo 'React Native, please report it here: https://github.com/facebook/react-native/issues'
    React Native, please report it here: https://github.com/facebook/react-native/issues
  • exit 2

React Native version:

System:
OS: macOS 11.5.2
CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
Memory: 914.61 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.22.1 - ~/.nvm/versions/node/v12.22.1/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.12 - ~/.nvm/versions/node/v12.22.1/bin/npm
Watchman: Not Found
Managers:
CocoaPods: 1.10.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
Android SDK:
API Levels: 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
Build Tools: 23.0.3, 25.0.2, 25.0.3, 27.0.3, 28.0.3, 29.0.0, 29.0.2, 29.0.3, 30.0.2
System Images: android-27 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 4.2 AI-202.7660.26.42.7486908
Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_201 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.65.1 => 0.65.1
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

@BenjErgizerBunny
Copy link

BenjErgizerBunny commented Sep 6, 2021

Have you found any solutions? This is only happening when running in release or staging mode, not debug. It's also happening when I archive as that is in release mode and preventing me from releasing an app update :(

The error was introduced when I upgraded from react-native 0.61.5. Auto upgrade didn't work and I used the upgrade helper

Environment:

  • react-native 0.65.1
  • react 17.0.2
  • node 16.8.0
  • Xcode Version 12.5.1 (12E507)

@tonypangs
Copy link

I also encountered this error when making an archive build. 😔

Environment

node: 14.17.6
react: 17.0.2
react-native: 0.65.1
realm: 10.7.0

@BenjErgizerBunny
Copy link

@taduyde and @tonypangs did this issue also begin after upgrading react-native from an older version or is this happening fro you with a fresh npx react-native init NewProject on 0.65.1?

@taduyde
Copy link
Author

taduyde commented Sep 7, 2021

@taduyde and @tonypangs did this issue also begin after upgrading react-native from an older version or is this happening fro you with a fresh npx react-native init NewProject on 0.65.1?

Hi @BenjErgizerBunny , both, from old and also use this command "npx react-native init NewProject"

@tonypangs
Copy link

I fixed this solution on my side.
It is becos the node version on xcode shell is below 14 which is not aligned with global environment.
(probably conflict of nvm and node)
You can check its version in xcode by adding node -v to react-native-xcode.sh
then inspect the version number in xcode error message.

To upgrade xcode node version, run
sudo npm install -g n
n install stable

@antoxi4
Copy link

antoxi4 commented Sep 14, 2021

I fixed this solution on my side.
It is becos the node version on xcode shell is below 14 which is not aligned with global environment.
(probably conflict of nvm and node)
You can check its version in xcode by adding node -v to react-native-xcode.sh
then inspect the version number in xcode error message.

To upgrade xcode node version, run
sudo npm install -g n
n install stable

I have same issue, and on global env i use node 14.17.3 the same in xcode 14.17.3. So i guess this trouble not in the node versions mismatch.

@egadstar
Copy link

I've hit this as well.

0.64.2 - Debug and Archive both work

0.65.1 - Debug works; however, Archive generates an error while creating the bundle during the "node /node_modules/react-native/cli.js bundle --entry-file index.js --platform ios --dev false --reset-cache --bundle-output..." cmd

If I run the command directly in my terminal, it is successful.

@aljs
Copy link
Contributor

aljs commented Sep 27, 2021

If you've installed node via brew, you can fix it by changing this line in Xcode Build Phases->Bundle React Native code and images:
export NODE_BINARY=node
to this one:
export NODE_BINARY=/usr/local/opt/node/bin/node

@schachris
Copy link

Any updates for this issue?
It happens with clean projects ... I tried a few:

  • "npx react-native init MyApp --template react-native-template-typescript"
  • "npx react-native init TestProjTS --template react-native-template-typescript --version 0.65.1"
  • "react-native init TestProj --version 0.65.1"

I always get the same error....
Its not working for archives and as soon as I set Scheme to Release

@murrple-1
Copy link

murrple-1 commented Oct 9, 2021

Thought I'd toss in... just a little above the error for me, there are a couple lines of errors during the bunding:

2021-10-09T15:12:52,310: [] while computing sockname: failed to create /usr/local/var/run/watchman/username-state: No such file or directory

Watchman:  watchman --no-pretty get-sockname returned with exit code=1, signal=null, stderr= 2021-10-09T15:12:52,310: [] while computing sockname: failed to create /usr/local/var/run/watchman/username-state: No such file or directory

might be a watchman issue?

@vuletuanbt
Copy link

Have you found any solutions? This is only happening when running in release or staging mode, not debug. It's also happening when I archive as that is in release mode and preventing me from releasing an app update :(

The error was introduced when I upgraded from react-native 0.61.5. Auto upgrade didn't work and I used the upgrade helper

Environment:

  • react-native 0.65.1
  • react 17.0.2
  • node 16.8.0
  • Xcode Version 12.5.1 (12E507)

I managed to resolve it. Go to Build Phased -> Bundle React Native code and images , change to

cd $PROJECT_DIR/..
export NODE_BINARY=node
./node_modules/react-native/scripts/react-native-xcode.sh

@Gabsys
Copy link

Gabsys commented Nov 12, 2021

If you've installed node via brew, you can fix it by changing this line in Xcode Build Phases->Bundle React Native code and images: export NODE_BINARY=node to this one: export NODE_BINARY=/usr/local/opt/node/bin/node

This solved the issue for me!

@rabiaasif
Copy link

If you've installed node via brew, you can fix it by changing this line in Xcode Build Phases->Bundle React Native code and images: export NODE_BINARY=node to this one: export NODE_BINARY=/usr/local/opt/node/bin/node

THIS WORKED FOR ME THANK YOU!!!!

@syedamirali14
Copy link

this command helped me npx react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios

@wSedlacek
Copy link

For those encountering this issue, it is probably coming from the /* Bundle React Native code and images */ section of your project.pbxproj

This is configured with a shellScript, typically export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh

The error specifically comes form this line here

if [[ $DEV != true && ! -f "$BUNDLE_FILE" ]]; then
echo "error: File $BUNDLE_FILE does not exist. This must be a bug with" >&2
echo "React Native, please report it here: https://github.com/facebook/react-native/issues"
exit 2
fi

It is prompted with the $BUNDLE_FILE does not exist while not making a dev build.
In my case this is because this line failed for me:

"$NODE_BINARY" $NODE_ARGS "$CLI_PATH" $BUNDLE_COMMAND \
$CONFIG_ARG \
--entry-file "$ENTRY_FILE" \
--platform "$BUNDLE_PLATFORM" \
--dev $DEV \
--reset-cache \
--bundle-output "$BUNDLE_FILE" \
--assets-dest "$DEST" \
$EXTRA_ARGS \
$EXTRA_PACKAGER_ARGS

The error it gave wasn't shown during the xcode build, by adding an echo at the start of line 153 to get the command it was running then run it manually.
In my case the error was

error The resource `/Users/wsedlacek/Code/temp/example/index.js` was not found.

In my project I didn't have a index.js as I was using a monorepo, so the ENTRY_FILE needed to be configured.
So I added ENTRY_FILE=apps/template/src/main.ts to prefix the react-native-xcode.sh command in the project.pbxproj and my issue was solved.

@JDMathew
Copy link
Contributor

JDMathew commented Mar 7, 2022

I fixed this by removing main.jsbundle from Copy Bundle Resources under Build Phases in Xcode

@lrob7325
Copy link

lrob7325 commented Aug 13, 2022

This was happening to me using Expo 46 and EAS. I spent 3 days trying to resolve it. A combination of things I found on StackOverflow and here helped. Step 6 was essential and critical for having successful EAS builds. Everything else after are for those using the latest version of Expo and React Native, and can't compile locally or on Expo's EAS server.

  1. ran "react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios"
  2. Added "main.jsbundle" to the Xcode workspace.
  3. Selected "Build Phases" and expanded "Copy Bundle Resources"
  4. Dragged (or you can click the + icon) main.jsbundle into the section
  5. In the "Bundle React Native code and images" I added the following script
  • export NODE_BINARY=node
    export PROJECT_ROOT=$PWD/..
    ../node_modules/react-native/scripts/react-native-xcode.sh
  1. I searched my repo for "main.jsbundle" and saw it was in the ".gitignore" and I removed all instances of it from the file.
  2. Now that the repo wasn't excluding the main.jsbundle file in uploads and zips, it was able to compile!

For Expo 45+ and/or React-Native 0.69.4 users:

  1. Since the latest version of React-Native deprecated ViewPropTypes, I ran "yarn add deprecated-react-native-prop-types"

  2. Then I created a folder called "scripts" as a subdirectory of "src"

  3. I located the "index.js" file in "node_modules/react-native" and copied it into my new "src/scripts" folder

  4. In the "src/scripts/index.js" file, I replaced the Deprecated Prop Types around lines 436 with:
    // Deprecated Prop Types
    get ColorPropType(): $FlowFixMe {
    return require("deprecated-react-native-prop-types").ColorPropType;
    },
    get EdgeInsetsPropType(): $FlowFixMe {
    return require("deprecated-react-native-prop-types").EdgeInsetsPropType;
    },
    get PointPropType(): $FlowFixMe {
    return require("deprecated-react-native-prop-types").PointPropType;
    },
    get ViewPropTypes(): $FlowFixMe {
    return require("deprecated-react-native-prop-types").ViewPropTypes;
    },
    };

  5. I then added the postinstall package to run commands after yarn is completed "yarn add postinstall"

  6. I added this script to copy the edited index.js to the node_modules/react-native folder after yarn install completes

  • "patch-react-native": "PATCH_PATH=$(pwd)/script_patches/react-native/index.js && NODE_PATH=$(pwd)/node_modules/react-native/index.js && cp $PATCH_PATH $NODE_PATH"
  1. Next add a postinstall script: "postinstall": "yarn patch-react-native"
  2. Now with all of these steps I provided, I was able to build locally and on the eas server since the index.js files is getting replaced.

Hopefully, all of this can help future devs, or at least bits and pieces. This was a 55 hours journey, and I really want to help those who were forced to upgrade due to 3rd party libraries. For me, it was the integration of the Square Reader SDK.

Lastly, I really wish I had all of the urls, and usernames to provide thanks, and give credit, to. It was a lot of googling with trial and error.

@jhoow
Copy link

jhoow commented Sep 8, 2022

this command helped me npx react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios

That's exactly what helped me too.

@Jongkeun
Copy link

It looks like react-native doesn't use /opt/homebrew/bin/watchman.
I added a symbolic link like this this fixed my issue.

ln -s  /opt/homebrew/bin/watchman /usr/local/bin/watchman 

@Manil-SoftNEP
Copy link

I solved this problem by running npx react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios command on the app's root terminal.

If a file called main.jsbundle is created inside your ios folder, then rebuild the app.
Else, it is likely that you got some output like

info Writing bundle output to:, ios/main.jsbundle
info Done writing bundle output
info Copying 61 asset files
warn Assets destination folder is not set, skipping...

If so go to
XCode >> {Your App} >> {Your App Target} Build Phases >> Bundle React Native code and images
and replace the node in export NODE_BINARY=node with the output of which node command executed on a different terminal.
update_node_path

Then re-run npx react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios and generate the main.jsbundle file.

Then add the file to your app by right clicking XCode >> {Your App} and selecting the Add files to "{Your App Name}" option. Then select the newly created main.jsbundle file. Check if the file is added to
XCode >> {Your App} >> {Your App Target} Build Phases >> Copy Bundle Resources

If the file is there, rebuild the app.

@iSaBo96
Copy link

iSaBo96 commented Mar 13, 2023

If i generate the bundle with "npx react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios" new, i get the error
error Failed to load configuration of your project. info Run CLI with --verbose flag for more details.

I i add "--verbose", no information given.

@wSedlacek
Copy link

@iSaBo96 I have experienced this issue when missing dependencies in my package.json.

You can try to run react-native config as documented here: https://github.com/react-native-community/cli/blob/main/docs/commands.md#config

If the config doesn't look right, or has an error running that command check that your package.json and react-native.config.js are configured properly. If you are using nx then make sure you have run nx sync-deps <project-name>

@otech47
Copy link

otech47 commented Apr 7, 2023

if you are using a monorepo/yarn workspaces you're going to want to define the PROJECT_ROOT at the top of your Bundle React Native code and images script

export PROJECT_ROOT=$PWD/..

that's the build phase that was failing for me and this fixed it ^

@andrei-ushakov-bw
Copy link

For me it turned out that one of the .js files imported a file from a directory with incorrect case (folder vs Folder). Happened because when changing the case of a file/directory git doesn't recognize it unless specified explicitly.
Make sure all your imports are correct.

@Vi-dot
Copy link

Vi-dot commented Jun 2, 2023

if you are using a monorepo/yarn workspaces you're going to want to define the PROJECT_ROOT at the top of your Bundle React Native code and images script

export PROJECT_ROOT=$PWD/..

that's the build phase that was failing for me and this fixed it ^

yeaaah thank you !

@pawan-sharma-yash
Copy link

I'm facing the same issue on an Intel based Mac. However, it completely works fine on an Apple silicon based Mac.
If anybody have any workaround then it will be a great help.

@NguyenVanVietPoLy
Copy link

  • export NODE_BINARY=node
    export PROJECT_ROOT=$PWD/..
    ../node_modules/react-native/scripts/react-native-xcode.sh

thanks!!!

@garkuwa
Copy link

garkuwa commented Aug 25, 2023

There are numerous reasons why you can get such an error "main.jsbundle does not exist". I got it when I my code had syntax errors (missing commas in styled-component entities), and I had to build the app with RN CLI instead of Xcode to see these errors.

@tranminhnhat1005
Copy link

tranminhnhat1005 commented Sep 25, 2023

I see that you have found a very good solution by creating a main.jsbundle file and adding it to the project.
But I also tried to find a different way with the intention of not creating a file but editing the $NODE_BINARY variable in /node_modules/react-native/scripts/react-native-xcode.sh.
I use the output of the which node command to copy the result and replace it in the following location:

"$NODE_BINARY" $NODE_ARGS "$CLI_PATH" $BUNDLE_COMMAND \ $CONFIG_ARG \ --entry-file "$ENTRY_FILE" \ --platform "$BUNDLE_PLATFORM" \ --dev $DEV \ --reset-cache \ --bundle-output "$BUNDLE_FILE" \ --assets-dest "$DEST" \ $EXTRA_ARGS \ $EXTRA_PACKAGER_ARGS

change to

which node => PATH_TO_NODE/node/v16.15.1/bin/node

"PATH_TO_NODE/node/v16.15.1/bin/node" $NODE_ARGS "$CLI_PATH" $BUNDLE_COMMAND \ $CONFIG_ARG \ --entry-file "$ENTRY_FILE" \ --platform "$BUNDLE_PLATFORM" \ --dev $DEV \ --reset-cache \ --bundle-output "$BUNDLE_FILE" \ --assets-dest "$DEST" \ $EXTRA_ARGS \ $EXTRA_PACKAGER_ARGS

Hope it useful.

@MrGru
Copy link

MrGru commented Sep 29, 2023

if you are using a monorepo/yarn workspaces you're going to want to define the PROJECT_ROOT at the top of your Bundle React Native code and images script

export PROJECT_ROOT=$PWD/..

that's the build phase that was failing for me and this fixed it ^

I'm using nx, do you know how to fix this issue with nx monorepo

@Harisene
Copy link

Harisene commented Jan 4, 2024

I recently upgraded my React Native project from 0.64.0 to 0.72. I'm also getting this issue.

@YASH-CODE1
Copy link

I fixed this by removing main.jsbundle from Copy Bundle Resources under Build Phases in Xcode

Such a simple solution, this is what exactly helped me, thanks a lot @JDMathew

@avinash-capsitech
Copy link

After added "main.jsbubdle" in iOS manually all latest changes are not update on file save and metro server disconnect after app successfully launched,Any solution...?

Thanks in advance

Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jul 17, 2024
@react-native-bot
Copy link
Collaborator

This issue was closed because it has been stalled for 7 days with no activity.

@react-native-bot react-native-bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 24, 2024
@nikolal
Copy link

nikolal commented Sep 25, 2024

My fix was:

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

Thanks to the: #32108 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests