2

I just started a project with react-create-app template typescript.

When I do npm run dev it opens edge browser, I was expecting chrome.

Any idea how to make it open in chrome?

angry kiwi
  • 9,824
  • 23
  • 98
  • 151
  • Does this answer your question? [create-react-app: How do I "npm start" with a specific browser?](https://stackoverflow.com/questions/51706882/create-react-app-how-do-i-npm-start-with-a-specific-browser) – Emile Bergeron Feb 15 '21 at 20:30

4 Answers4

3

From Create React App documentation

By default, Create React App will open the default system browser, favoring Chrome on macOS. Specify a browser to override this behavior, or set it to none to disable it completely. If you need to customize the way the browser is launched, you can specify a node script instead. Any arguments passed to npm start will also be passed to this script, and the url where your app is served will be the last argument. Your script's file name must have the .js extension.

Easy answer is to change your default browser. However if you want to keep your default browser to Edge you can do this.

BROWSER=chrome npm start
BROWSER=chrome npm run dev

Consider that browser names are different. For example, Chrome is google chrome on macOS, google-chrome on Linux and chrome on Windows.

Linux
"start": "BROWSER='google-chrome-stable' react-scripts start"
Windows
"start": "BROWSER='chrome' react-scripts start"
Mac
"start": "BROWSER='google chrome' react-scripts start"
sadrzadehsina
  • 1,275
  • 13
  • 24
  • This helped me. But I'll make an amendment. I had to do this: (in Win10) "start": "set BROWSER='chrome'; react-scripts start" I use FireFox for most of my web projects. However, in this instance I need Chrome. So, I can't just change the default at the OS/IDE level. – lerenau Sep 18 '21 at 23:38
0

Likely it opens in your default browser, this is an OS setting.

0

This question might probably gives the answer: create-react-app: How do I "npm start" with a specific browser?

In short: "By default, Create React App will open the default system browser, favoring Chrome on macOS." from the documentation. My guess is that your default browser is set to Edge, and if you set it to Chrome, it will open it in Chrome instead.

Barnabas Ujvari
  • 329
  • 3
  • 5
0

To solve this, I need to give a default setting in vscode. It was empty, so I fill in chrome.

angry kiwi
  • 9,824
  • 23
  • 98
  • 151