react-native-cli: 2.0.1
react-native: 0.59.4
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/
Which version of Node do you use? Can you run react-native info?
Sure.
info
React Native Environment Info:
System:
OS: macOS 10.14.3
CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
Memory: 1019.41 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.15.3 - /usr/local/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/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.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.4 => 0.59.4
npmGlobalPackages:
create-react-native-app: 2.0.2
react-native-cli: 2.0.1
We'll definitely need a repo which we can download and investigate. Please provide one
I'm not sure I am able to give access to this repo. Here is the output from Android Studio. Does this help?
`> Task :app:bundleReleaseJsAndAssets FAILED
/PROJECT/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.
at Module._compile (module.js:556:32)
`
Is there a possibility that your Android Studio uses different Node version, i.e. below 8.3?
I don't think but Im not very experienced with Android Studio. Do you know where I would check that? If I build debug it works fine. Release builds throw up this error
I do see
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
in the App/build.gradle
`node -v
v6.4.0
If this helps also
React Native (and this CLI as well) doesn't support Node 6. You need to use Node 8.3+. Please upgrade and the error will be gone :)
android _kane7161$ node -v
v10.15.3
I still see the issue
I've updated all of my modules also
Interesting fact: when you ran react-native info to provide us with details of your package, it also used the cliEntry.js file where you have your error reported. Please fix your environment, I have no ways to do so unfortunately.
Also make sure you're running the latest version of @react-native-community/cli, which is 1.9.2 (remove it from lockfile and install react-native again)
@thymikee Can you explain a bit more about the first issue you described? Im not sure I follow what you mean
I'm talking about this message: https://github.com/react-native-community/cli/issues/342#issuecomment-485552401.
The error comes from node_modules/@react-native-community/cli/build/cliEntry.js:168 which is used when running any command, e.g. react-native info. So I just say it's weird you get a syntax error when running one command, but not the other.
If you can't share the project, you can create a sample one and show me the error. Or record a video that shows what actions do you perform that result in this problem.
@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.
@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.1Since
nvmand paths can be a little crazy I addedconsole.log('Node: ' + process.version);just before the token error and I seeNode: v10.15.3on 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 tonvmis probably using my default node version (not v10.15.3). I then rannvm alias default v10.15.3and now it builds.
I was having the same problem. This solution works.
Is there a possibility that your Android Studio uses different Node version, i.e. below 8.3?
I have similar error, the reason is different node version, I have two node, there a path setting in .bash_profile is different with the one (node@6/bin), I temporary set in command window as different one.
Now I change the path setting in .bash_profile to same with the command window(node/bin)
this issue disappear.
Thanks for reminder
/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.
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
Process terminated. Press
Facing same problem with rn version 0.61.1 please help me out to solve this err!!
facing the same error
/home/supu/Documents/Projects/ProjectUniq/node_modules/@react-native-community/cli/build/cliEntry.js:124
let output = [_chalk().default.bold(react-native ${cmdName} ${this.usage()}), 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:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
/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. (/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 to close the windowFacing same problem with rn version 0.61.1 please help me out to solve this err!!
@madeeha96
Some of my coworkers are facing the same issue like you. It might be something related to node, they work with different version using nvm but I used just one version (12.6.3). Everything work fine on my laptop but not theirs.
Most helpful comment
@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:Since
nvmand paths can be a little crazy I addedconsole.log('Node: ' + process.version);just before the token error and I seeNode: v10.15.3on 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 tonvmis probably using my default node version (not v10.15.3). I then rannvm alias default v10.15.3and now it builds.