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?
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?
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"
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.
(Windows) It may very well be a default web browser situation in which you'll need to do a search for Default apps --> click on the current browser under Web browser --> select preferred browser.
I made the mistake of installing Microsoft Edge on my Mac. I didn't set it to the default web browser and verified that Chrome is the default.
However, ever since then, when I run npm start
, the development server insists on trying to launch the app in Edge. Even after deleting Edge, it prompts: "Choose Application - Where is Microsoft Edge?"
So I simply chose Google Chrome at that prompt, which I tried to avoid but couldn't quickly find an alternative.
The other answers aren't quite correct. VSCode's choice of which browser to open is a bit ... idiosyncratic. Chrome is used by default (if it's installed) on MacOS, regardless of whether it's the OS's default browser. I don't have a Windows machine, but it sounds like Edge might be getting the same treatment there.
To make VSCode use your OS's actual default browser, you'll need to prefix your NPM script entry with an assignment statement that clears the value of the BROWSER
variable. It'll look something like this:
"scripts": {
"frontend": "BROWSER= npm start",
...
}
Note the empty space after BROWSER=
in the command above. This sets the value of the variable to [nothing], which triggers VSCode using your OS default browswer.
To solve this, I need to give a default setting in vscode. It was empty, when it's empty, vscode will open edge, that's their favorite browser, it's hard code in their app, so open the vs setting and set the default to chrome. Before I set the default to chrome. it was empty ""
.