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

Cannot start react-native run-ios or run-android after initializing #31284

Closed
Jtomage opened this issue Apr 1, 2021 · 10 comments
Closed

Cannot start react-native run-ios or run-android after initializing #31284

Jtomage opened this issue Apr 1, 2021 · 10 comments
Labels
Needs: Triage 🔍 Resolution: For Stack Overflow A question for Stack Overflow. Applying this label will cause issue to be closed. Resolution: Locked This issue was locked by the bot.

Comments

@Jtomage
Copy link

Jtomage commented Apr 1, 2021

Cannot copy and paste had to retype.

~/node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/index.js:48
} catch {}
^
SyntaxError: unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisConetxt (vm.js:139:10)
at Module._compile (module.js:617:28)
..

Description

The error above occurs after initializing a blank project.

  1. Ran npx react-native init [Project-Name]
  2. Ran npx react-native run-ios or npx react-native run-android

Metro pops up in another terminal tab with the error above.

React Native version:

System:
OS: macOS 10.15.7
cpu: (16) x64 Intel(R) Core(TM) i8-988H CPU @ 2.30GHz
memory: 13.79 GB / 32.00 GB
shell: 5.7.1 - /bin/zsh
Binaries:
Node: 15.13.0 - ~/.nvm/..
Yarn: Not found
npm: 7.7.6 ~./nvm/...
watchman: not found
Managers:
CocoaPods: 1.10.1 - /usr/local/bin/pod
SDK:
iOS SDK:
Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
android SDK:
API Levels: 23, 27, 29, 30
Build Tools: 23.0.1, 25.0.1, 25.0.2, 26.0.1, 26.0.2, 27.0.3, 28.0.3, 29.0.0, 30.0.3
System images: android-23 | Google APIs Intel x86 Intel x86 Atom, anroid-27
npmPackages:
@react-native-community/cli: not found
react: 17.0.1 > 17.0.1
react-native: 0.64.0 =>0.64.0
react-native-macos: not found
npmGlobalPackages
react-native: not found

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. Ran npx react-native init [Project-Name]
  2. Ran npx react-native run-ios or npx react-native run-android

Expected Results

Expecting the emulators to pop up with welcome screen

@ugglr
Copy link

ugglr commented Apr 6, 2021

+1 I find this issue incredibly annoying, only issue on iOS.

@yerevin
Copy link

yerevin commented Apr 16, 2021

I ran into same issue when upgraded from 63.3 to 64.0
Steps I did to run into issue:

  1. Pulled changes (because did upgrade not on Mac)
  2. rm -rf node_modules and package-lock
  3. npm install (with Node 8v - there is problem probably)
  4. cd ios and pod install - here comes error

How fixed:

  1. rm -rf node_modules and package-lock
  2. loaded nvm with . ~/.nvm/nvm.sh (and got Node at v14.15.0)
  3. npm install
  4. (npx) react-native run-ios (got here error)
  5. cd ios and pod install
  6. (npx) react-native run-ios (this time worked and had app running on simulator)
    6* for me default metro bundler in new terminal window run into error from issue but it was probably because of default Node v8, so i run (npx) react-native start in same window where I ran 6) step

So issue is probably due to Node version

@vcmoraes
Copy link

https://reactnative.dev/blog/2021/03/12/version-0.64#major-dependency-version-changes - "Minimum Node support bumped from 10 to Node 12", tks @yerevin

@javierjim
Copy link

I had to issues:

  1. I used nvm to manage node versions and the default was set to older than node 12
    -Fixed it by calling nvm alias default DESIRED_VERSION
  2. I forgot to uninstall globally react-native-cli. Once I did this step, when calling npx react-native init ProjectName I saw the new console UI with the React logo; something I was not seeing before.

After those two steps I was good to go and things worked correctly for me.

@adkaushik
Copy link

I have the same issue on android studio. The app runs successfully from terminal though

@udaysagartammina
Copy link

I am also getting the same error.

  • node /Users/user/Documents/Examples/node_modules/react-native/cli.js bundle --entry-file index.js --platform ios --dev false --reset-cache --bundle-output /Users/user/Library/Developer/Xcode/DerivedData/StepUp-arcbdgjhmmvylwbgivrtxllexdqe/Build/Intermediates.noindex/ArchiveIntermediates/StepUp/BuildProductsPath/Release-iphoneos/main.jsbundle --assets-dest /Users/user/Library/Developer/Xcode/DerivedData/StepUp-arcbdgjhmmvylwbgrtxllexdqe/Build/Intermediates.noindex/ArchiveIntermediates/StepUp/BuildProductsPath/Release-iphoneos/StepUp.app
    /Users/user/Documents/Examples/node_modules/react-native/node_modules/@react-native-community/cli/build/commands/doctor/healthchecks/index.js:48
    } catch {}
    ^

SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object. (/Users/user/Documents/Examples/node_modules/react-native/node_modules/@react-native-community/cli/build/commands/doctor/doctor.js:28:21)
Command PhaseScriptExecution failed with a nonzero exit code

@yeyintkoko
Copy link

It's because of node version. But just logging out of the computer and switching node version to latest with nvm, doesn't work.
The issue is solved only when I restart my computer (my MacBook). Then I removed node_modules and reinstall packages. Then all work.

@valeriashpiner
Copy link

valeriashpiner commented Aug 10, 2021

For me, it appears on ios and android, when I try to run on real devices after upgrade to 0.64.
I cleaned the cache, reinstall everything, reboot the laptop, use the latest node - nothing helped.

@safaiyeh safaiyeh added the Resolution: For Stack Overflow A question for Stack Overflow. Applying this label will cause issue to be closed. label Aug 10, 2021
@github-actions
Copy link

We are using GitHub issues exclusively to track bugs in the core React Native library. Please try asking over on Stack Overflow as it is better suited for this type of question.

@muditjuneja
Copy link

I had to issues:

  1. I used nvm to manage node versions and the default was set to older than node 12
    -Fixed it by calling nvm alias default DESIRED_VERSION
  2. I forgot to uninstall globally react-native-cli. Once I did this step, when calling npx react-native init ProjectName I saw the new console UI with the React logo; something I was not seeing before.

After those two steps I was good to go and things worked correctly for me.

@javierjim answer helped me. It was the issue with node only. Thanks man!!

@facebook facebook locked as resolved and limited conversation to collaborators Aug 10, 2022
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Aug 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs: Triage 🔍 Resolution: For Stack Overflow A question for Stack Overflow. Applying this label will cause issue to be closed. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests