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.

main.jsbundle does not exist. This must be a bug with React Native. metro/src/lib/polyfills/require.js: Unexpected token, expected ","

See original GitHub issue

Archive in XCode lead to the error: main.jsbundle does not exist. This must be a bug with React Native. metro/src/lib/polyfills/require.js: Unexpected token, expected “,”

React Native version:

info 
  React Native Environment Info:
    System:
      OS: macOS 10.14.5
      CPU: x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
      Memory: 257.27 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 10.14.1 - ~/.nvm/versions/node/v10.14.1/bin/node
      Yarn: 1.16.0 - ~/.yarn/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v10.14.1/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
    IDEs:
      Android Studio: 3.3 AI-182.5107.16.33.5264788
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      @storybook/react: ^5.0.11 => 5.0.11 
      @storybook/react-native: ^4.1.18 => 4.1.18 
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.8 => 0.59.8 
    npmGlobalPackages:
      react-native-cli: 2.0.1

Steps To Reproduce

  1. XCode 10.2.1 (10E1001) > Product > Archive
  2. Got error:
+ BUNDLE_FILE=/Users/<mac-user-name>/Library/Developer/Xcode/DerivedData/********-dnnaonnrphjpphhhgmjunutlpwgi/Build/Intermediates.noindex/ArchiveIntermediates/********/BuildProductsPath/Release-iphoneos/********.app/main.jsbundle
+ node /opt/local/var/www/********/********-app/node_modules/react-native/cli.js bundle --entry-file index.js --platform ios --dev false --reset-cache --bundle-output /Users/<mac-user-name>/Library/Developer/Xcode/DerivedData/********-dnnaonnrphjpphhhgmjunutlpwgi/Build/Intermediates.noindex/ArchiveIntermediates/********/BuildProductsPath/Release-iphoneos/********.app/main.jsbundle --assets-dest /Users/<mac-user-name>/Library/Developer/Xcode/DerivedData/********-dnnaonnrphjpphhhgmjunutlpwgi/Build/Intermediates.noindex/ArchiveIntermediates/********/BuildProductsPath/Release-iphoneos/********.app
warning: the transform cache was reset.
Loading dependency graph, done.
error SyntaxError: /opt/local/var/www/********/********-app/node_modules/metro/src/lib/polyfills/require.js: Unexpected token, expected "," (341:5)

  339 |       _moduleObject.exports,
  340 |       dependencyMap
> 341 |     ); // avoid removing factory in DEV mode as it breaks HMR
      |      ^
  342 | 
  343 |     if (!__DEV__) {
  344 |       // $FlowFixMe: This is only sound because we never access `factory` again. Run CLI with --verbose flag for more details.
+ [[ false != true ]]
+ [[ ! -f /Users/<mac-user-name>/Library/Developer/Xcode/DerivedData/********-dnnaonnrphjpphhhgmjunutlpwgi/Build/Intermediates.noindex/ArchiveIntermediates/********/BuildProductsPath/Release-iphoneos/********.app/main.jsbundle ]]
+ echo 'error: File /Users/<mac-user-name>/Library/Developer/Xcode/DerivedData/********-dnnaonnrphjpphhhgmjunutlpwgi/Build/Intermediates.noindex/ArchiveIntermediates/********/BuildProductsPath/Release-iphoneos/********.app/main.jsbundle does not exist. This must be a bug with'
error: File /Users/<mac-user-name>/Library/Developer/Xcode/DerivedData/********-dnnaonnrphjpphhhgmjunutlpwgi/Build/Intermediates.noindex/ArchiveIntermediates/********/BuildProductsPath/Release-iphoneos/********.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

node_modules/metro/package.json

  "version": "0.51.1",
  "name": "metro",
  ...
  "repository": {
    "type": "git",
    "url": "git@github.com:facebook/metro.git"
  },

node_modules/metro/src/lib/polyfills/require.js

    if (hooks.length > 0) {
      for (var i = 0; i < hooks.length; ++i) {
        hooks[i].cb(moduleId, _moduleObject);
      }
    } // keep args in sync with with defineModuleCode in
    // metro/src/Resolver/index.js
    // and metro/src/ModuleGraph/worker.js

    factory(
      global,
      metroRequire,
      metroImportDefault,
      metroImportAll,
      _moduleObject,
      _moduleObject.exports,
      dependencyMap
    ); // avoid removing factory in DEV mode as it breaks HMR

    if (!__DEV__) {
      // $FlowFixMe: This is only sound because we never access `factory` again
      module.factory = undefined;
      module.dependencyMap = undefined;
    }

meanwhile react-native run-ios works without any errors.

Related issues: #15432

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

21reactions
kuzyakievcommented, Jun 25, 2019

Fixed it with @nishiltamboli and @nadbm comments from #15432

I had a similar problem with node version. What I did was

Open console and type the command > which node Copied the node path (in my case it came out to be /Users/<mac-user-name>/.nvm/versions/node/v10.14.1/bin/node) Open Xcode project Open Project > Build Phases > Bundle React Native code and images 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=/Users/<mac-user-name>/.nvm/versions/node/v10.14.1/bin/node …/node_modules/react-native/scripts/react-native-xcode.sh

Thats it! Hope it helps someone.

15reactions
2j2ecommented, Feb 25, 2020

Other case. I had the next line of code:

__DEV__ = false

(don’t judge me) which doesn’t break anything during the development, but breaks the build during release with original error message in the topic. Any developer can have similar issue which breaks babel step, but you will find it as soon as you’ll run bundle command

react-native bundle --minify --entry-file index.js --platform ios --dev false --bundle-output main.jsbundle

In my case the response was pretty clear:

TypeError: Property left of AssignmentExpression expected node to be of a type ["LVal"] but instead got "BooleanLiteral"```
Read more comments on GitHub >

github_iconTop Results From Across the Web

ios - main.jsbundle does not exist. This must be a bug with ...
This worked for me in a project involving babel-plugin-module-resolver : Open your ios/*.xcworkspace in Xcode.
Read more >
Main.Jsbundle Does Not Exist. This Must Be A Bug ... - ADocLib
Archive in XCode lead to the error: main.jsbundle does not exist. This must be a bug with React Native. metro/src/lib/polyfills/require.js: Unexpected token ......
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 >
React native source not found for app:///main.jsbundle - #sentry
I've uploaded my main.jsbundle and the main.jsbundle.map for my React Native project. The sourcemap was uploaded with the rewrite and strip ...
Read more >
react-native: main.jsbundle does not exist. - Ananda - Medium
BuildProductsPath/Release-iphoneos/....app/main.jsbundle does not exist. ... node_modules/react-native/local-cli/cli.js bundle --platform ios --entry-file ...
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