React Native: "error Cannot start server in new window because no terminal app was specified" [closed]
Asked Answered
B

8

17

After updating to React Native v73.1, I'm getting the below error when trying to run the app in Windows:

error Cannot start server in new window because no terminal app was specified.

How can I fix it?

On a Mac machine, there aren't any issues. Only Windows is facing this issue.

Bidding answered 19/12, 2023 at 9:52 Comment(3)
Are you facing this issue in the VS Code or Terminal?Mccutchen
both place facing same issuesBidding
new terminal run the "npm start" and open second new terminal/powershell to execute command in "npx react-native run-android --mode=release".Bidding
M
4

I had the same issue using React Native 0.73.1, when I had to run release mode.

In the case of debug mode, you can simply use npm start and then a.

However, if you want to run release mode, use npm start to run Metro, open a new terminal and execute npx react-native run-android --mode=release.

This worked in my case.

Myramyrah answered 20/12, 2023 at 9:28 Comment(3)
is their any way to fix it and make it work like it wasAksum
npx react-native run-android --terminal powershellDistichous
i don't think this should be count as answer, just add "--terminal <your terminal > after "npx react-native run-androd". your terminal could be "cmd.exe", "powershell.exe" or "bash" etc, depends your enviroment. as @naveedahmed commented above.Czardom
M
10

It looks like Metro has lost support for Windows Terminal and only allows a Bash terminal. I had to launch it once in Git Bash, and keep the Metro window open, before being able to launch React Native in Windows Terminal.

It seems there isn't much we can do, aside from waiting for React Native and Metro to fix it.

I have created an issue there: Metro on Windows: Cannot start server in new window because no terminal app was specified #1160

Enter image description here

Menides answered 20/12, 2023 at 1:38 Comment(0)
L
10

You can try to use the "npm run start" script.

Image

Lampkin answered 20/12, 2023 at 7:15 Comment(1)
Please review Why not upload images of code/errors when asking a question? (e.g., "Images should only be used to illustrate problems that can't be made clear in any other way, such as to provide screenshots of a user interface.") and do the right thing (it covers answers as well). Thanks in advance.Ganger
G
6

It was a bug introduced in the latest React Native CLI. I already pushed a fix for that, and the upcoming React Native CLI should work fine.

Until then, you can use:

npm run start

And then press A to start the Android build.

Goldagoldarina answered 31/12, 2023 at 4:7 Comment(0)
M
4

I had the same issue using React Native 0.73.1, when I had to run release mode.

In the case of debug mode, you can simply use npm start and then a.

However, if you want to run release mode, use npm start to run Metro, open a new terminal and execute npx react-native run-android --mode=release.

This worked in my case.

Myramyrah answered 20/12, 2023 at 9:28 Comment(3)
is their any way to fix it and make it work like it wasAksum
npx react-native run-android --terminal powershellDistichous
i don't think this should be count as answer, just add "--terminal <your terminal > after "npx react-native run-androd". your terminal could be "cmd.exe", "powershell.exe" or "bash" etc, depends your enviroment. as @naveedahmed commented above.Czardom
S
2

As referenced in this issue, there is a new --terminal flag where you pass the path to the terminal you want to open. It's still not ideal but it works. For example:

react-native run-android --active-arch-only --mode=devDebug --terminal='C:\\Program Files\\PowerShell\\7\\pwsh.exe'
Spearwort answered 21/12, 2023 at 9:38 Comment(0)
T
0

Please try => "npx react-native start" script.

Toft answered 20/12, 2023 at 12:20 Comment(0)
C
-1

Try this code. It will work.

npm run start
Connubial answered 24/12, 2023 at 22:6 Comment(0)
D
-1

If you would like to use Yarn, you can run this on your project folder with Git Bash, which then opens Windows Terminal on the side.

yarn android

Note: running this in Windows Terminal will not work!

Dextrosinistral answered 29/12, 2023 at 0:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.