cli: Bundling Android async function run() error

Environment

react-native-cli: 2.0.1 react-native: 0.59.4

Description

I am attempting to bundle the android project using this

react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

However I am getting this error

node_modules/@react-native-community/cli/build/cliEntry.js:168
async function run() {
      ^^^^^^^^
SyntaxError: Unexpected token function
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:528:28)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/_kane7161/

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 19 (6 by maintainers)

Most upvoted comments

@mikeKane here is what I found to solve this …

I just did a fresh install for the first time using the instructions at https://facebook.github.io/react-native/docs/getting-started (including a newly installed Node v10.15.3 via nvm) and I’m seeing this for both iOS and Android but not for react-native info:

react-native info
info
  React Native Environment Info:
    System:
      OS: macOS 10.14.4
      CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
      Memory: 10.94 GB / 32.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.15.3 - ~/.nvm/v10.15.3/bin/node
      Yarn: 1.10.1 - /usr/local/bin/yarn
      npm: 6.9.0 - ~/.nvm/v10.15.3/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
      Android SDK:
        API Levels: 18, 19, 21, 22, 23, 25, 26, 27, 28, 7
        Build Tools: 19.0.3, 19.1.0, 21.1.1, 21.1.2, 22.0.0, 22.0.1, 23.0.1, 23.0.2, 25.0.0, 25.0.1, 25.0.2, 26.0.1, 26.0.2, 27.0.2, 27.0.3, 28.0.3
        System Images: android-18 | Intel x86 Atom, android-19 | ARM EABI v7a, android-19 | Intel x86 Atom, android-21 | Android TV ARM EABI v7a, android-21 | Android TV Intel x86 Atom, android-21 | Android Wear ARM EABI v7a, android-21 | Android Wear Intel x86 Atom, android-21 | ARM EABI v7a, android-21 | Intel x86 Atom, android-21 | Intel x86 Atom_64, android-21 | Google APIs ARM EABI v7a, android-21 | Google APIs Intel x86 Atom, android-21 | Google APIs Intel x86 Atom_64, android-22 | Android TV ARM EABI v7a, android-22 | Android TV Intel x86 Atom, android-22 | Android Wear ARM EABI v7a, android-22 | Android Wear Intel x86 Atom, android-22 | ARM EABI v7a, android-22 | Intel x86 Atom, android-22 | Intel x86 Atom_64, android-22 | Google APIs ARM EABI v7a, android-22 | Google APIs Intel x86 Atom, android-22 | Google APIs Intel x86 Atom_64, android-26 | Android Wear Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 3.4 AI-183.5429.30.34.5452501
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3
      react-native: 0.59.5 => 0.59.5
    npmGlobalPackages:
      react-native-cli: 2.0.1

Since nvm and paths can be a little crazy I added console.log('Node: ' + process.version); just before the token error and I see Node: v10.15.3 on my console. I’m running this from iTerm, where the node version is reported, but the error it presented in a new native Mac Terminal.app window. Suspecting foul play I scrolled up in that new window and saw it running /Users/matt/src/temp/react-native-test/CrossPlatformTest/node_modules/react-native/scripts/launchPackager.command, which due to nvm is probably using my default node version (not v10.15.3). I then ran nvm alias default v10.15.3 and now it builds.

/Users/madeeha/Desktop/allergy-app/allergyApp/node_modules/react-native/node_modules/@react-native-community/cli/build/cliEntry.js:131 let output = [_chalk().default.bold(react-native ${cmdName} ${argsList}), this._description ? \n${this._description}\n : ‘’, …sourceInformation, ${_chalk().default.bold('Options:')}, this.optionHelp().replace(/^/gm, ’ ')]; ^^^

SyntaxError: Unexpected token … at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:373:25) at Object.Module._extensions…js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object.<anonymous> (/Users/madeeha/Desktop/allergy-app/allergyApp/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:5:40) at Module._compile (module.js:409:26) at Object.Module._extensions…js (module.js:416:10) Process terminated. Press <enter> to close the window

Facing same problem with rn version 0.61.1 please help me out to solve this err!!