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

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

Closed
ColtraneNadler opened this issue Mar 3, 2021 · 26 comments
Closed
Labels
DX Issues concerning how the developer experience can be improved. Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Platform: iOS iOS applications.

Comments

@ColtraneNadler
Copy link

ColtraneNadler commented Mar 3, 2021

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!

@ColtraneNadler
Copy link
Author

Bump here

@safaiyeh safaiyeh added DX Issues concerning how the developer experience can be improved. Platform: iOS iOS applications. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. and removed Needs: Triage 🔍 labels Mar 9, 2021
@safaiyeh
Copy link
Contributor

safaiyeh commented Mar 9, 2021

@ColtraneNadler could you check out this issue: facebook/create-react-app#4540 (comment)

to see if it solves your problem

@github-actions
Copy link

github-actions bot commented Mar 9, 2021

⚠️ Missing Reproducible Example
ℹ️ It looks like your issue is missing a reproducible example. Please provide a Snack or a repository that demonstrates the issue you are reporting in a minimal, complete, and reproducible manner.

@jsamr
Copy link

jsamr commented Mar 9, 2021

@safaiyeh Not the OP, but facing the same issue (RN 0.63.4) and I already have the latest version of watchman installed from brew (4.9.0_5). I'm on an Apple Silicon macbook 2020.

React Native Info
System:
    OS: macOS 11.2.2
    CPU: (8) arm64 Apple M1
    Memory: 409.72 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 15.9.0 - /opt/homebrew/bin/node
    Yarn: 2.4.0 - /opt/homebrew/bin/yarn
    npm: 7.5.3 - /opt/homebrew/bin/npm
    Watchman: 4.9.0 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
    Xcode: 12.4/12D4e - /usr/bin/xcodebuild
  Languages:
    Java: Not Found
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.4 => 0.63.4 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

References

Reproduction

I tried to reproduce the issue in a blank project, but unfortunately, archiving from XCode requires a provisioning profile which can be granted with an Apple developer license, which I don't have.

@jsamr
Copy link

jsamr commented 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
...

@iacocesar
Copy link

same here

@Fortidude
Copy link

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.

@nitaking
Copy link

nitaking commented Apr 15, 2021

I work it:

touch ios/main.jsbundle

npx react-native run-ios

@javioli-devbase
Copy link

I have the same issue with RN 0.63.3 , I tried all solutions here, but nothing worked , Can anyone help me?

@ithustle
Copy link

I ran Metro bundle with sudo and Build was successful.
Why is that? Because every time the process was near to end, the Metro lose connection to watchman and build fall

@OtavioBraga
Copy link

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

Worked like a charm for me!

@priyankaEdufund
Copy link

priyankaEdufund commented Nov 30, 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
...

YOU SAVED MY LIFE <3
Thank you soo much! :)

@liqiankl
Copy link

I have the same issue with RN 0.63.3 , I tried all solutions here, but nothing worked , Can anyone help me?

I've been facing this issue lately was there any fix to this, seem like its been a while

@nguyenvanphuc2203
Copy link

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

YOU SAVED MY LIFE <3
Thank you soo much! :)

@codesalley
Copy link

Open project ios folder in Xcode, goto build phases in Copy Bundle Resources tab remove main.jsbundle
Screenshot 2022-06-16 at 5 36 39 PM

@mungbeans2
Copy link

mungbeans2 commented Nov 11, 2022

Hello, I don't understand the description of

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

Hello, I don't understand the description of the issue and the fix. The problem is described as "but not configured for /bin/sh". So if things aren't configured for /bin/sh then why do the solutions involve configuring homebrew/bin (which is already configured according to the description) and not configuring /bin/sh?

@jjrise
Copy link

jjrise commented Nov 30, 2022

I'd imagine for most users who still can't solve this with any of the above steps have an issue with their javascript. I had a package/dependency issue and that solved it.

@JuxhinB
Copy link

JuxhinB commented Dec 1, 2022

NODE_BINARY

this actually works, archive doesn't

@mungbeans2
Copy link

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'

I had fixed this error by the way tried use "II. Quick and dirty fix". Thank you so much!

I don't understand what you are saying - this new file that gets created under /etc/paths.d/ what should it be called? It can be called anything? And what should it contain? You're implying it should contain the line sudo -s 'echo "/opt/homebrew/bin" > /etc/paths.d/200-homebrew' ?
So that does mean you've named your file 200-homebrew, and then that file contains a line of sudo -s 'echo "/opt/homebrew/bin" > /etc/paths.d/200-homebrew' So its self referential?

@github-actions
Copy link

This issue is waiting for author's feedback since 24 days. Please provide the requested feedback 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 Mar 13, 2023
@popking5466
Copy link

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

piccolo@Piccolos-MacBook-Pro ios % sudo -s 'echo "/opt/homebrew/bin" > /etc/paths.d/200-homebrew'
Password:
zsh:1: no such file or directory: echo "/opt/homebrew/bin" > /etc/paths.d/200-homebrew

I create an empy file named 200-homebrew in /etc/paths.d/ but still not work. Can you help me?

@github-actions github-actions bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Mar 16, 2023
@vishalenrique
Copy link

vishalenrique commented Mar 26, 2023

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

My React Native Info

React Native Environment Info:
System:
OS: macOS 12.6.3
CPU: (10) x64 Apple M1 Pro
Memory: 24.65 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 10.13.0 - ~/.nvm/versions/node/v10.13.0/bin/node
Yarn: 1.22.19 - ~/.yarn/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v10.13.0/bin/npm
Watchman: 2023.02.20.00 - /opt/homebrew/bin/watchman
SDKs:
iOS SDK:
Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
Android SDK:
API Levels: 23, 28, 29, 33
Build Tools: 28.0.3, 29.0.2, 33.0.2
System Images: android-30 | Google Play ARM 64 v8a, android-31 | Google APIs ARM 64 v8a
IDEs:
Android Studio: 2022.1 AI-221.6008.13.2211.9514443
Xcode: 14.2/14C18 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.10 => 0.59.10

Can someone please explain why the above solution works?

Edit: Added the react native info

@github-actions
Copy link

This issue is waiting for author's feedback since 24 days. Please provide the requested feedback 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 Apr 19, 2023
@github-actions
Copy link

This issue was closed because the author hasn't provided the requested feedback after 7 days.

@github-actions github-actions bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Apr 26, 2023
@penghaogit
Copy link

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

This solved my problem

@PriyaBapodra
Copy link

@OtavioBraga Your solution worked for me ! Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX Issues concerning how the developer experience can be improved. Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Platform: iOS iOS applications.
Projects
None yet
Development

No branches or pull requests