question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Description

App won’t build for release scheme, therefore won’t archive. I have watchman installed. I can build for debug, just not release.

React Native version:

0.63.4 Node version is v14.15.5

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. Build for Release scheme

Expected Results

For the build to succeed

Snack, code example, screenshot, or link to a repository:

During the build process…

BUNDLE_FILE=/Users/coltrane/Library/Developer/Xcode/DerivedData/mobile-dsdtbnudpwicuuckveptihmuzeuy/Build/Products/Release-iphonesimulator/mobile.app/main.jsbundle
+ /usr/local/bin/node /Users/coltrane/Documents/Apps/Storyboard/social/mobile/node_modules/react-native/cli.js bundle --entry-file index.js --platform ios --dev false --reset-cache --bundle-output /Users/coltrane/Library/Developer/Xcode/DerivedData/mobile-dsdtbnudpwicuuckveptihmuzeuy/Build/Products/Release-iphonesimulator/mobile.app/main.jsbundle --assets-dest /Users/coltrane/Library/Developer/Xcode/DerivedData/mobile-dsdtbnudpwicuuckveptihmuzeuy/Build/Products/Release-iphonesimulator/mobile.app
warning: the transform cache was reset.
                 Welcome to React Native!
                Learn once, write anywhere


events.js:292
      throw er; // Unhandled 'error' event

Error: EMFILE: too many open files, watch
    at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:178:28)
Emitted 'error' event on NodeWatcher instance at:
    at NodeWatcher.checkedEmitError (/Users/coltrane/Documents/Apps/Storyboard/social/mobile/node_modules/sane/src/node_watcher.js:143:12)
    at FSWatcher.emit (events.js:315:20)
    at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:184:12) {
  errno: -24,
  syscall: 'watch',
  code: 'EMFILE',
  filename: null
}
+ [[ false != true ]]
+ [[ ! -f /Users/coltrane/Library/Developer/Xcode/DerivedData/mobile-dsdtbnudpwicuuckveptihmuzeuy/Build/Products/Release-iphonesimulator/mobile.app/main.jsbundle ]]
echo 'error: File /Users/coltrane/Library/Developer/Xcode/DerivedData/mobile-dsdtbnudpwicuuckveptihmuzeuy/Build/Products/Release-iphonesimulator/mobile.app/main.jsbundle does not exist. This must be a bug with'

In my build phases, I have it set to

export NODE_BINARY=$(which node)
../node_modules/react-native/scripts/react-native-xcode.sh

I’ve tried:

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

and other variations of the solutions on issue #29351 which didn’t work either.

Please help!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:10
  • Comments:18

github_iconTop GitHub Comments

41reactions
jsamrcommented, Mar 11, 2021

I found the issue on my end. It was because of my $PATH environment variable, which was set to /opt/homebrew/bin for zsh, but not configured for /bin/sh. This path is used by the metro bundler to identify the presence of watchman; that’s why the reported error was symptomatic of a missing watchman install! (thanks @safaiyeh ).

I. Generic solution with path_helper

path_helper is a very handy utility shipped with MacOS to construct the PATH environment for any shell, and it’s the Apple recommended way to share a path globally. To add a path, you just need to create a new file under /etc/paths.d/ with one or more lines containing each a path:

sudo -s 'echo "/opt/homebrew/bin" > /etc/paths.d/200-homebrew'

Unfortunately, /bin/sh run from XCode 12.4 doesn’t seem to source /etc/profile which in turns should call path_helper, but we can force this behavior by sourcing it ourselves. Add these lines in the very beginning of “Bundle React native code and images” build phase script:

if [ -f /etc/profile ]; then
    . /etc/profile
fi
export NODE_BINARY=node
...

II. Quick and dirty fix

An alternative is to hardcode the homebrew path in the shell script. I find it less generic but certainly straightforwards. Add this line in the very beginning of “Bundle React native code and images” build phase script:

export PATH="$PATH:/opt/homebrew/bin"
export NODE_BINARY=node
...
6reactions
Fortidudecommented, Mar 16, 2021

Above “II. Quick and dirty fix” :

export PATH="$PATH:/opt/homebrew/bin"
export NODE_BINARY=node
...

did the job in my case.

I have this issue from time to time, but only when running archive. Sometimes it’s working for a few days, and then I have to reinstall node, watchmen, brew, switch between node versions (10-15) and sometimes it just click and works. and than - after next 1-3 weeks it doesn’t work once again 😃

I think somehow sometimes Xcode CLI when building archive can’t run watchman. Buildng debug on simulator/physical works fine, only the archive is problematic.

Read more comments on GitHub >

github_iconTop Results From Across the Web

main.jsbundle does not exist. This must be a bug with #29356
I even checked the dir and indeed, there is NO main.jsbundle file in there. I updated vom 0.63.2 to 0.63.4, I tried pretty...
Read more >
main.jsbundle does not exist. this must be a bug with + echo ...
I got this problem after installing 'react-native-purchases' for some reason ( this library only work with rn version 0.64+ so maybe related ...
Read more >
main.jsbundle does not exist [fixed] | by Onexlab - Medium
Make sure you're running a packager server or have include a .jsbundle file in your application bundle. It will show you the prompt...
Read more >
main.jsbundle does not exist. this must be a bug with + echo ...
Coding example for the question main.jsbundle does not exist. this must be a bug with + echo 'react native-React Native.
Read more >
RN IOS xproj build failed : main.jsbundle does not exist
Bitrise Build Issue Report template Foosby.app/main.jsbundle does not exist. This must be a bug with Last lines of the Xcode's build log: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found