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. This must be a bug with + echo 'React Native #15432

Closed
hanishsharma opened this issue Aug 9, 2017 · 51 comments
Closed
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@hanishsharma
Copy link

Hello team,

I am getting this error while running my xcode project.

main.jsbundle does not exist. This must be a bug with + echo 'React Native.

Please help.

Thanks.

@IbraheemAlSaady
Copy link

IbraheemAlSaady commented Aug 12, 2017

This happens when there is no offline bundle file in your project, I had the same problem and this worked for me.

If you're running on the device, check the Running On Device docs

I added the below to my package.json file so I don't have to type it every time I want to generate an offline bundle

"build:ios": "react-native bundle --entry-file='index.ios.js' --bundle-output='./ios/YourAppName/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'"

And you can run it like this npm run build:ios

You'll see the main.jsbundle file generated inside your ios/YourAppName directory

Next, open your project using XCode, right click on your project name then click Add Files to "YourProjectName", choose the main.jsbundle file that was generated, and then build again.

That should do it.

I'm using

"react": "16.0.0-alpha.12",
"react-native": "0.46.1",

@scottyantipa
Copy link

scottyantipa commented Aug 15, 2017

Not sure if this is the answer, but this issue went away for me when I moved my type declaration packages from devDependencies to dependencies in package.json.

The packages were @types/react, @types/react-native, @types/react-navigation.

@lolobosse
Copy link

@scottyantipa Can you elaborate on that? What packages? and what type declaration? That would help me a lot! 😄

@scottyantipa
Copy link

@lolobosse I updated my comment above

@lolobosse
Copy link

@scottyantipa I found my error, it was a weird \ in a string.

I had to debug the bundler and I saw the file crashing.

@reactnative Team: that would be great that if the --verbose option is activated, you deliver more logs than just SyntaxError on the bundler 😄

@cconstable
Copy link

cconstable commented Sep 4, 2017

For this issue was caused because the index.ios.js file was not located in the root directory of the repo. I had to modify the Build Phases -> Bundle React Native code and images script in Xcode to point it to the correct directory.

Original (what react native generated):

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

Fixed:

export NODE_BINARY=node
../node_modules/react-native/scripts/react-native-xcode.sh ./src/index.ios.js

@xavieramoros
Copy link

I had a similar error after doing a pull of a repo upgraded to 0.48.4 (someone else did the RN upgrading).

Doing
rm -rf ./node_modules && npm install
showed this error, but doing:
rm -rf ./node_modules && yarn
actually fixed it. So I guess there are subtle differences on how yarn and git handle install scripts.

@johndanek
Copy link

@lolobosse What string was the / in? React Native code, or somewhere in XCode?

@jpapillon
Copy link

@johndanek The node_modules directory is always at the root of your project (React Native code).

@JamesDorrian
Copy link

JamesDorrian commented Nov 7, 2017

Tried all of above, problem still persisting. Why was this closed @hanishsharma ?

@YasirSherzad
Copy link

Hi , I am using react-native 0.49, I get this error on device only , it works fine on Simulator. I tried many things but none worked.

img-0652

@JamesDorrian
Copy link

@hanishsharma Why did you close this?

@MoOx
Copy link
Contributor

MoOx commented Nov 24, 2017

I just got this, and that was just that the bundle wasn't building correctly.

I started dev mode and found an fatal error that were blocking compilation (a bad require). It was that simple.

@jordanmkoncz
Copy link

jordanmkoncz commented Nov 28, 2017

I had this issue as well when I tried to create an archive in Xcode.

For me, it was because the command to build the JS bundle was failing, and the reason it was failing was because one of my dependencies had a specific babel preset in its .babelrc file, which I did not have installed in my main React Native project's package.json.

In the Xcode error output, a few lines above the "main.jsbundle does not exist" line, I had the following error message from the react-native bundle command that had run:

TransformError: /Users/jordan/Development/MyAppName/node_modules/dotenv-parse-variables/lib/index.js: Unknown plugin "add-module-exports" specified in "/Users/jordan/Development/MyAppName/node_modules/dotenv-parse-variables/.babelrc" at 0, attempted to resolve relative to "/Users/jordan/Development/MyAppName/node_modules/dotenv-parse-variables"

So I installed the missing plugin by running: yarn add --dev babel-plugin-add-module-exports

I then went to Xcode again, did a Product -> Clean, then Product -> Archive, and this time it worked.

I actually used to have these dependency-related babel plugins installed, but I removed them because the release notes for 0.50.0 (https://github.com/facebook/react-native/releases/tag/v0.50.0) stated that this wouldn't be required anymore due to the change in enableBabelRCLookup. But I guess that change isn't quite working correctly, so for now we'll have to keep using the workaround I used here, or the postinstall workaround that they describe in those release notes.

For reference, here's my dependencies:

"react": "16.0.0",
"react-native": "0.50.3"

@unmec
Copy link

unmec commented Nov 28, 2017

Just to share something that I've found out about this issue.

  • I can build for debug, but when build for release, RN throws the error

  • Clean different sorts of cache / reinstall node npm / change xcode settings etc have nothing to do with my issue

  • A clean new project with react-native init has exactly the same issue

  • Sometimes it's caused by typos, you can build for debug to see if its caused by typos. If debug build succeeds, then your js files are all OK

  • If you have checked all above items and still face the issue, finally, it's probably due to your network environment. When you develop on some internal networks that have atypical settings of firewall, you might face this issue. Just disable your wifi network on you Mac, then build for release on your phone / simulator, it should run as expected.

Took me some good 2 hours to find it out.

@viethaca
Copy link

viethaca commented Nov 28, 2017

i have same problem, i use
"react": "16.0.0-alpha.12"
"react-native": "0.48.4"
i change in "node_modules/react-native/scripts/react-native-xcode.sh"
ENTRY_FILE=${1:-index.ios.js}
to
ENTRY_FILE=${1:-index.js}

@asleepace
Copy link

asleepace commented Dec 8, 2017

The problem for me had to do with Apple's iCloud syncing my desktop and documents. For me the fix was moving the folder to a directory that wasn't synced with icloud in my ~ directory. I cloned the repo from git and stopped having these issues. Hope this helps someone, lost two days on this...

@dwilt
Copy link

dwilt commented Dec 25, 2017

The key here is to look in Xcode, above the "main.jsbundle does not exist" message and see what the actual reason for the bundle not being created is:

image

In my case, the actual error (TransformError: /Users/dwilt/Documents/GitHub/the-resistance/firebaseFunctions/gameStructure.js: Cannot read property 'useBuiltIns' of undefined) was caused from the release build failing to import a file from outside my src directory - but only when building for release. Not sure why yet but moving the file to the src directory solved it.

@saqbach
Copy link

saqbach commented Jan 7, 2018

Not sure if I'm doing this correctly but I had this issue when trying to run react-native run-ios after following the steps for running on device and getting the app ready for publishing to the app store.

I removed the following to enable App Transport Security:

<key>NSAppTransportSecurity</key>
  <dict>
    <key>NSExceptionDomains</key>
    <dict>
      <key>localhost</key>
      <dict>
        <key>NSExceptionAllowsInsecureHTTPLoads</key>
        <true/>
      </dict>
    </dict>
  </dict>

However, if I don't add it back in to my Info.plist when I want to debug, then I get the main.jsbundle missing error.

@petarivanovv9
Copy link

Hello guys! I tried everything that I read through github issues and google but I can't still find the solution for me. When I'm using the simulator everything is fine but when I try to make an archive or build it on my phone I have this error:

File /Users/.../Library/Developer/Xcode/DerivedData/<app_name>-cyixycawuftgogfcezlrqhtzvdyo/Build/Intermediates.noindex/ArchiveIntermediates/<app_name>/BuildProductsPath/Release-iphoneos/<app_name>.app/main.jsbundle does not exist

My dependencies are:

"react": "16.0.0",
"react-native": "0.50.3",

I will be very happy if anyone could help me because I am stuck with this issue from 2 days and I can't submit my app for test flight.

@npalethorpe
Copy link

Just had this issue myself, turns out it was caused due to a space in one of my higher up folder names. I removed the space from the name and it sprang into life!

@HermitCarb
Copy link

Find another case: Wrong case in file name。

> react-native bundle --entry-file='index.js' --bundle-output='./ios/StrongBox/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'
Scanning folders for symlinks in /Users/carb/WorkSpace/ReactNative/strong-box/node_modules (17ms)
Scanning folders for symlinks in /Users/carb/WorkSpace/ReactNative/strong-box/node_modules (32ms)
Loading dependency graph, done.
Loading dependency graph...
Unable to resolve module `./tools/UmPush` from `/Users/carb/WorkSpace/ReactNative/strong-box/src/main.js`: could not resolve `/Users/carb/WorkSpace/ReactNative/strong-box/src/tools/UmPush' as a file nor as a folder

The actual filename is UMPush.js, I thought it was UmPush.js, and git ignored it. (I changed the char case of file name and forgot git.😔)

@treyp
Copy link

treyp commented Feb 2, 2018

Looks like the issue with spaces in the CLI path was fixed in #17628.

@jsdario
Copy link
Contributor

jsdario commented Feb 13, 2018

Hi, is there any difference in using unbundle as BUNDLE_COMMAND? https://facebook.github.io/react-native/docs/performance.html#unbundling-inline-requires

I am experiencing the following issue: https://stackoverflow.com/questions/48751053/react-native-unbundle-app-gets-hung-in-release

@xeieshan
Copy link

@cconstable @IbraheemAlSaady

Both your solutions didn’t work for me

"build:ios": "react-native bundle --entry-file='index.ios.js' --bundle-output='./ios/YourAppName/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'"

&

export NODE_BINARY=node
../node_modules/react-native/scripts/react-native-xcode.sh ./src/index.ios.js

@Loxrie
Copy link

Loxrie commented Mar 6, 2018

@xeieshan

It seems to have worked for me, I had to add the file into xcode and add it into the "Build Phases"->"Copy Bundle Resources" in the target.

Assuming you've modified AppDelegate.m to load the resource instead of using RCTBundleURLProvider:

jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

@WoodyWoodsta
Copy link

Ran into this issue today and it turns out that invoking the build via a yarn script was the culprit. Using npm run or just the raw commandline worked fine for me!

@miguelacio
Copy link

i did what IbraheemAlSaady told us to do and my app is having a a really weird behavior, it change all my aplications images/icons to the ios/ folder, I dont know why or how this happened, please help my boss is gonna fire me

@isAlmogK
Copy link

I'm having a similar issue has anyone had this issue before - https://stackoverflow.com/questions/49313917/react-native-app-can-build-for-debugging-but-not-for-archiving

@Stas-Buzunko
Copy link

got this error when library was added but forgot to run npm i / yarn
npm i fixed it

@matteocollina
Copy link

matteocollina commented Apr 4, 2018

This is my script : Create jsbundle and import to XCode.
NB: I've integrated React-Native into an existing native app, so my RN code in into /js folder.

https://gist.github.com/matteocollina/ee92ee698ddfefceb8ce85c9d94d69df

if [ "$CONFIGURATION" == "Debug" ]; then
  echo "Debug Configuration"
else
  echo "Release Configuration"
  cd js
  react-native bundle --platform ios --dev false --entry-file index.ios.js --bundle-output main.jsbundle
  RESOURCE_PATH=$SRCROOT/js
  FILENAME_IN_BUNDLE=main.jsbundle
  BUILD_APP_DIR=${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app
  cp $RESOURCE_PATH/$FILENAME_IN_BUNDLE $BUILD_APP_DIR/$FILENAME_IN_BUNDLE
  echo "Copied jsbundle √"
fi

@LivioGama
Copy link

None of everything above worked for me. I had to change .babelrc file to :

{
  "presets": ["react-native"],
  "plugins": ["transform-decorators-legacy"],
  "sourceMaps": true
}

@thegamenicorus
Copy link

thegamenicorus commented Apr 19, 2018

For me, it's because of remove some packages (via npm uninstall/yarn remove) but still have references in Xcode project.

The solution is goto Build Settings, then remove node_modules reference of deleted packages in "Framework Search Path" and "Header Search Paths".

Hope it help someone here.

@futurechallenger
Copy link

Look above of the error, you will fine what exactly wrong when the shell script trying to package your js file.
My problem is that I missed a , in an object definition!

Noitidart pushed a commit to Noitidart/Trusted-Score-Mobile that referenced this issue May 5, 2018
* build:ios was added to package.json only needed so i can run it to see why it was failing - the sh script auto does this, and with better args, this one i just copied from - facebook/react-native#15432 (comment) - doing this told me trasnform-remove-console was missing, and yes i had forgot to npm i that on the mac, it was only on windows
* it also seems in release version i always get entitlement error, but if i archive it and install it works
@jbcrestot
Copy link

Like many people, I came across this topic when I had the same mistake, which is why I want to share what really caused the problem :
Context :
We(@kisioDigitial) build our apps through jenkins which use fastlane (for release purpose), we didn't had any problem till 1 month but during this month we upgrade our react-native version from :
{ "react": "16.0.0-alpha.6", "react-native": "^0.44.0" }
to
{ "react": "^16.2.0", "react-native": "^0.52.2"}

It turns out that it's the same problem that npalethorpe got (#15432 (comment)), Jenkins create directory workspace according to the build name which in our case had several spaces.

I'm not 100% sure that issue come from the react-native upgrade, but removing the space from the build name (so from the directory name) resolve the issue and build no longer fail on the main.jsbundle missing file

@enieber
Copy link

enieber commented May 24, 2018

this occurred when I had a problem in directory js modules

@dzpt
Copy link

dzpt commented Jun 1, 2018

@IbraheemAlSaady

npm run build:ios
npm ERR! missing script: build:ios

got this error after execute command

@small3flower
Copy link

Useing Xcode to open the iOS project will solve this problem.

@xyz150462
Copy link

I find an easy way to solve it . you just run your project using simulator while not your Device at the first time. After you do it, it will have a local main.jsbundle file automatically and then you can run it on your Device success. it works for me, hope so with you.

@noahtallen
Copy link

I'm getting the issue when doing CD builds on Bitrise using the Xcode archive and export step. Here's the last bit of the log:

▸ Running script 'Bundle React Native code and images'
    the transform cache was reset.

❌  error: File /Users/vagrant/Library/Developer/Xcode/DerivedData/zonder-dfxxvabfiixsrgbdsqgwkghxwehd/Build/Intermediates.noindex/ArchiveIntermediates/zonder/BuildProductsPath/Release-iphoneos/zonder.app/main.jsbundle does not exist. This must be a bug with React Native, please report it here: https://github.com/facebook/react-native/issues'

I'm confused because the build has been working very well for us for quite some time, and it just started failing. Additionally, I can't reproduce the issue locally via normal debug builds or via a local Xcode archive in release mode. Any thoughts on what I should look into next? I'm thinking about trying to nuke the node_modules cache for yarn first.

@deehuey
Copy link

deehuey commented Jul 3, 2018

Thanks @futurechallenger , actual error was above the highlighted error!

@luolin2611
Copy link

@gfly 你搞定这个问题了?

@tibbus
Copy link

tibbus commented Jul 24, 2018

For me it works on my local machine but it fails on the bitrise build, locally works with node 8 and 10 but on bitrise works only with node 8 (only with yarn)

@ahaus
Copy link

ahaus commented Jul 30, 2018

I got the error "main.jsbundle does not exist" when I upgraded from 0.46.4 to 0.47.
What helped in my case was to add or rename index.ios.js to just index.js.
After this it worked fine.

@nadbm
Copy link

nadbm commented Aug 18, 2018

For me, the build process was using an old version of node. I had it installed via nvm so modified the following (in Build Phases > Bundle React Native code)

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

to

export NODE_BINARY=/Users/nadim54321/.nvm/versions/node/v10.3.0/bin/node
../node_modules/react-native/scripts/react-native-xcode.sh

@ashokseervidev
Copy link

ashokseervidev commented Aug 30, 2018

react-native bundle --entry-file ./index.ios.js --platform ios --bundle-output ios/main.jsbundle

Run this command it should work.

@rkuncewicz
Copy link

In case none of this works for you, restarting my Mac fixed the issue 🤯

@luolin2611
Copy link

luolin2611 commented Sep 13, 2018 via email

@vynogradskyi
Copy link

vynogradskyi commented Oct 2, 2018

Hi All,
Did anyone faced this type of the issue?

/Users/vvinogradskiy/Work/eversleep/new/everSleep-React/node_modules/rx/dist/rx.all.js: Cannot convert object to primitive value
TypeError: Cannot convert object to primitive value
    at _evaluate (/Users/vvinogradskiy/Work/eversleep/new/everSleep-React/node_modules/@babel/traverse/lib/path/evaluation.js:287:21)
    at evaluateCached (/Users/vvinogradskiy/Work/eversleep/new/everSleep-React/node_modules/@babel/traverse/lib/path/evaluation.js:45:17)
    at NodePath.evaluate (/Users/vvinogradskiy/Work/eversleep/new/everSleep-React/node_modules/@babel/traverse/lib/path/evaluation.js:405:15)
    at evaluate (/Users/vvinogradskiy/Work/eversleep/new/everSleep-React/node_modules/metro/src/JSTransformer/worker/constant-folding-plugin.js:30:30)
    at PluginPass.exit (/Users/vvinogradskiy/Work/eversleep/new/everSleep-React/node_modules/metro/src/JSTransformer/worker/constant-folding-plugin.js:79:22)
    at newFn (/Users/vvinogradskiy/Work/eversleep/new/everSleep-React/node_modules/@babel/traverse/lib/visitors.js:193:21)
    at NodePath._call (/Users/vvinogradskiy/Work/eversleep/new/everSleep-React/node_modules/@babel/traverse/lib/path/context.js:53:20)
    at NodePath.call (/Users/vvinogradskiy/Work/eversleep/new/everSleep-React/node_modules/@babel/traverse/lib/path/context.js:40:17)
    at NodePath.visit (/Users/vvinogradskiy/Work/eversleep/new/everSleep-React/node_modules/@babel/traverse/lib/path/context.js:97:8)

+ [[ false != true ]]
+ [[ ! -f /Users/vvinogradskiy/Library/Developer/Xcode/DerivedData/Eversleep2-bevmscnfjrhzdogjjxvskkcgvvpe/Build/Products/Release-iphoneos/Eversleep2.app/main.jsbundle ]]
+ echo 'error: File /Users/vvinogradskiy/Library/Developer/Xcode/DerivedData/Eversleep2-bevmscnfjrhzdogjjxvskkcgvvpe/Build/Products/Release-iphoneos/Eversleep2.app/main.jsbundle does not exist. This must be a bug with'
error: File /Users/vvinogradskiy/Library/Developer/Xcode/DerivedData/Eversleep2-bevmscnfjrhzdogjjxvskkcgvvpe/Build/Products/Release-iphoneos/Eversleep2.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
"@babel/core": "^7.1.2",
"@babel/runtime": "^7.1.2",
"babel-jest": "23.6.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.47.0",
"react-test-renderer": "16.5.0"


"react": "16.5.0",
"react-native": "0.57.1",

UPDATE: Found issue, unused import of
import { AsyncSubject } from 'rx'; in one of the files. 3 days of pain

@razor313
Copy link

razor313 commented Oct 6, 2018

Hi everyone, I got this error invalid asset resolution after I run this command react-native bundle --entry-file ./index.ios.js --platform ios --bundle-output ios/main.jsbundle

Environment

OS: macOS 10.14
Node: 10.11.0
Yarn: 1.9.4
npm: 6.4.1
Watchman: 4.9.0
Xcode: Xcode 9.4.1 Build version 9F2000
Android Studio: 3.2 AI-181.5540.7.32.5014246

##Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.4 => 0.55.4

Description

When I want to make the archive (IPA) file or run this command react-native bundle --entry-file ./index.ios.js --platform ios --bundle-output ios/main.jsbundle I face with this error

Scanning folders for symlinks in /Users/(UserName)/(AppName)-IPA/trunk/node_modules (18ms)
Scanning folders for symlinks in /Users/(UserName)/(AppName)-IPA/trunk/node_modules (28ms)
Loading dependency graph, done.
warning: the transform cache was reset.

invalid asset resolution

+ [[ false != true ]]
+ [[ ! -f /Users/(UserName)/Library/Developer/Xcode/DerivedData/(AppName)-cnblsqqaiazcukboapcwusllmldm/Build/Intermediates.noindex/ArchiveIntermediates/dara/BuildProductsPath/Release-iphoneos/(AppName).app/main.jsbundle ]]
+ echo 'error: File /Users/(UserName)/Library/Developer/Xcode/DerivedData/(AppName)-cnblsqqaiazcukboapcwusllmldm/Build/Intermediates.noindex/ArchiveIntermediates/(AppName)/BuildProductsPath/Release-iphoneos/(AppName).app/main.jsbundle does not exist. This must be a bug with'
error: File /Users/(UserName)/Library/Developer/Xcode/DerivedData/(AppName)-cnblsqqaiazcukboapcwusllmldm/Build/Intermediates.noindex/ArchiveIntermediates/(AppName)/BuildProductsPath/Release-iphoneos/(AppName).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

Reproducible Demo

I follow this https://stackoverflow.com/questions/49505446/main-jsbundle-does-not-exist-this-must-be-a-bug-with-echo-react-native

It would be great if help me :)

@nishiltamboli
Copy link

I got it working, thanks to @nadbm . I had a similar problem with node version. My global node version read 8.9.1. What I did was

  1. Open console and type the command > which node
  2. Copied the node path (in my case it came out to be /usr/local/bin/node)
  3. Open Xcode project
  4. Open Project > Build Phases > Bundle React Native code and images
  5. Change

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

to

export NODE_BINARY=<PATH_FROM_WHICH_NODE>
../node_modules/react-native/scripts/react-native-xcode.sh

So for me, I changed it to

export NODE_BINARY=/usr/local/bin/node
../node_modules/react-native/scripts/react-native-xcode.sh

Thats it! Hope it helps someone.

"react": "16.5.0",
"react-native": "0.57.1",

@facebook facebook locked as resolved and limited conversation to collaborators Oct 13, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests