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

Windows: Cannot start server in new window because no terminal app was specified #2219

Closed
feng-yu-healthbank opened this issue Dec 20, 2023 · 31 comments · Fixed by #2236
Closed

Comments

@feng-yu-healthbank
Copy link

feng-yu-healthbank commented Dec 20, 2023

Do you want to request a feature or report a bug?

Report a bug

It's originally raised on StackOverflow https://stackoverflow.com/questions/77684266/react-native-error-cannot-start-server-in-new-window-because-no-terminal-app-wa/77688826

What is the current behavior?

When launching react-native metro on Windows, it gets "error Cannot start server in new window because no terminal app was specified".

If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test.

It's really just a fresh react-native project using the standard init.

npx react-native@latest init AwesomeProject && cd ./AwesomeProject && npm run android

If you don't like to run it yourself, I have created a repo for you. No customization whatsoever, just a fresh react-native project.

https://github.com/feng-yu-healthbank/AwesomeProject

Please note the error is specific to Windows.

What is the expected behavior?

The empty project launches into an Android emulator by npm run android.

Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.

It's a fresh official react-native sample project. No customization is applied.

Metro version

"metro": "^0.80.0"

metro config:

const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');

/**
 * Metro configuration
 * https://facebook.github.io/metro/docs/configuration
 *
 * @type {import('metro-config').MetroConfig}
 */
const config = {};

module.exports = mergeConfig(getDefaultConfig(__dirname), config);

npx react-native info

System:
  OS: Windows 11 10.0.22621
  CPU: (24) x64 13th Gen Intel(R) Core(TM) i7-13700K
  Memory: 27.55 GB / 63.77 GB
Binaries:
  Node:
    version: 20.10.0
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 1.22.19
    path: ~\AppData\Roaming\npm\yarn.CMD
  npm:
    version: 9.7.1
    path: C:\Program Files\nodejs\npm.CMD
  Watchman:
    version: 20231008.002904.0
    path: C:\ProgramData\chocolatey\bin\watchman.EXE
SDKs:
  Android SDK:
    Android NDK: 22.1.7171670
  Windows SDK:
    AllowAllTrustedApps: Disabled
    Versions:
      - 10.0.19041.0
IDEs:
  Android Studio: AI-231.9392.1.2311.11076708
  Visual Studio: Not Found
Languages:
  Java: 17.0.9
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.1
    wanted: 0.73.1
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

image

@feng-yu-healthbank feng-yu-healthbank changed the title Metro on Windows: Cannot start server in new window because no terminal app was specified Windows: Cannot start server in new window because no terminal app was specified Dec 20, 2023
@Navpan18
Copy link

Facing same issue

@Navpan18
Copy link

this problem is occuring from react native version 0.72.9

@coder-xiaomo
Copy link

Same here. I upgraded from react-native@0.72 to react-native@0.73.1, and then, the problem occurred.

I found a temporary solution that is to use npm run start or npm start instead of npm run android mentioned in this stackoverflow page

@Navpan18
Copy link

App works fine till react native version 0.72.8 . Problem begins from 0.72.9

@Navpan18
Copy link

Same here. I upgraded from react-native@0.72 to react-native@0.73.1, and then, the problem occurred.

I found a temporary solution that is to use npm run start or npm start instead of npm run android mentioned in this stackoverflow page

Check if your app works fine in RN 0.72.8

@szymonrybczak
Copy link
Collaborator

Hey @Navpan18, @coder-xiaomo can you try passing via --terminal flag a path to executable file of your terminal? and say if that is working :)

@james-cohen
Copy link

james-cohen commented Dec 21, 2023

Hey @Navpan18, @coder-xiaomo can you try passing via --terminal flag a path to executable file of your terminal? and say if that is working :)

This works for me. However it only opens a new window and doesn't automatically run andoid, it acts as if you've run react-native start only

@szymonrybczak
Copy link
Collaborator

This works for me. However it only opens a new window and doesn't automatically run andoid, it acts as if you've run react-native start only

Interesting, can you please record a video which presents this behaviour?

@james-cohen
Copy link

Sure, I've recorded 2 GIFs below. When I run 'yarn android:test' it is the following npm script:

react-native run-android --active-arch-only --mode=devDebug

The first video, you can see that even after waiting for over a minute, the Android build doesn't start. You have to press a in the Metro terminal but then all of the parameters are lost

metro1

This second video, I run the same script with Metro already running and the Android build starts immediately

metro2

@abbasbphppoets
Copy link

Sure, I've recorded 2 GIFs below. When I run 'yarn android:test' it is the following npm script:

react-native run-android --active-arch-only --mode=devDebug

The first video, you can see that even after waiting for over a minute, the Android build doesn't start. You have to press a in the Metro terminal but then all of the parameters are lost

metro1 metro1

This second video, I run the same script with Metro already running and the Android build starts immediately

metro2 metro2

doesn't work

@WesleyMaciel2510
Copy link

Same issue, trying to solve it.

@dezudas
Copy link

dezudas commented Dec 29, 2023

+1
$ react-native run-ios --simulator 'iPhone 15'
error Cannot start server in new window because no terminal app was specified.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@phuthien007
Copy link

Same issue, trying to solve it.

temporary is run script: npx react-native start and after that type mode a

@rishimagiawala
Copy link

Same issue, trying to solve it.

temporary is run script: npx react-native start and after that type mode a

This works for me, thx.

I ran "npx react-native start", then hit "a" when it gave me the option to

@Shreyas-29
Copy link

Try running the following command:😊

npx react-native start

@jslok
Copy link

jslok commented Jan 1, 2024

Getting this bug on windows+android on 0.73.1. Works fine on 0.73.0. Not tested on mac/ios.

@machadinha
Copy link

machadinha commented Jan 1, 2024

When i run "npx react-native start", then hit "a" it gives me this
image
what do i do im in windowns

@yetki
Copy link

yetki commented Jan 2, 2024

I fix my problem with

npx react-native run-android --terminal powershell

however I want to use only npx react-native run-android

@Shreyas-29
Copy link

When i run "npx react-native start", then hit "a" it gives me this image what do i do im in windowns

Yes. I am also getting that error.
But don't know how to fix it. I am unable to run the app on neither physical device nor android studio.

@szymonrybczak
Copy link
Collaborator

szymonrybczak commented Jan 2, 2024

@machadinha @Shreyas-29 for you it is not working because you don't have ANDROID_HOME env variable provided - please re-read an error message and try setting in your system setting - also it may be helpful to run npx react-native doctor and make sure it is passing :)

@szymonrybczak
Copy link
Collaborator

however I want to use only npx react-native run-android

you can also do npx react-native run-android --terminal

@machadinha

This comment was marked as resolved.

@machadinha
Copy link

machadinha commented Jan 2, 2024

@machadinha @Shreyas-29 for you it is not working because you don't have ANDROID_HOME env variable provided - please re-read an error message and try setting in your system setting - also it may be helpful to run npx react-native doctor and make sure it is passing :)

Its resolved I thinks

@yetki
Copy link

yetki commented Jan 3, 2024

however I want to use only npx react-native run-android

you can also do npx react-native run-android --terminal

PS FILE_PATH> npx react-native run-android --terminal
error: option '--terminal ' argument missing

It was asking string like node, powershell etc.

@linq8261
Copy link

linq8261 commented Jan 6, 2024

however I want to use only npx react-native run-android

you can also do npx react-native run-android --terminal

PS FILE_PATH> npx react-native run-android --terminal error: option '--terminal ' argument missing

It was asking string like node, powershell etc.

npx react-native run-android --terminal C:\Windows\System32\cmd.exe

@Francisco420

This comment was marked as resolved.

@XinrZhou
Copy link

npm run start
npm start
npx react-native start
Try the above commands~

@faraz-stack
Copy link

faraz-stack commented Jan 12, 2024

Simple Solution
Run npx react-native start
and after when metro starts successfully and gives you Dev server ready options hit a to run on android and i to run on iOS.
it works for me on android with react native version 0.73.
With react-native version 0.73 it aslo require you to have Java jdk 17.
Capture

@raphaelrb96
Copy link

Eu resolvo meu problema com

npx react-native run-android --terminal powershell

no entanto, quero usar apenas npx react-native run-Android

funcionou!!

@abid-2362
Copy link

on MacOS M1 14.2.1 (23C71)

react-native run-android --terminal terminal

worked for me, and then for easy access, I added this under the scripts in package.json file

"android": "react-native run-android --terminal terminal",
"ios": "react-native run-ios --terminal terminal",

and then yarn android works fine

@RobertSavage
Copy link

RobertSavage commented Feb 16, 2024

Running: npx react-native run-ios or run ios or react-native run-ios --terminal terminal
Error: EACCES: permission denied

Running: sudo npx react-native run-ios or sudo run ios or sudo react-native run-ios --terminal terminal
Error: Cannot start server in new window because no terminal app was specified.

Fix: As suggested above I ran npm run start with my simulator open. It did not start the app up for me like it usually does but I was able to click into the app and it was running.

MacOS Sonoma 14.1
Apple M3 Pro
React Native v0.73

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.