4

I created a react app with creact-react-app. I launch the app with npm start. If I create the .env file with

BROWSER=google-chrome-stable
PORT=4000

The port is correctly configured, but the default browser is always launched. No matter if I sorround the browser with single quotes, double quotes, no quotes, or if google-chrome-stable, firefox or chromium-browser is used. A npm start always launches the default browser.

I also tried launching in the command line with BROWSER or changind the start section of the poackage.json file nothing works.

Only BROWSER=none works.

I also checked several other SO posts, also reinstalled, etc. nothing seems to solve the issue.

Versions are:

  • ubuntu 20.04
  • node 16.13.1
  • npm 8.1.2
  • react 17.0.2
  • react-dom 17.0.2
  • react-scripts 5.0.0

any hints?

Thank you!

1
  • Were you able to find a solution for this? Commented Mar 23, 2022 at 7:40

3 Answers 3

2

It's a bug.

There is a fix https://github.com/facebook/create-react-app/pull/11878 and some bug reports are referenced there.

Sign up to request clarification or add additional context in comments.

Comments

2

Here is the workaround that worked for me until the cra bug is not fixed.

  1. Add the following to package.json:
    "overrides": {
        "open": "7.4.2"
    }
  1. Remove node_modules and package-lock.json
  2. Run npm install

This requires npm-cli ver. 8.3 or later. For yarn use resolutions instead of overrides.

The .env file content that worked for me:

BROWSER=chrome

1 Comment

As of today, this is the only solution that works on windows 11 as far as I tell.
0

Just insert "chrome": "BROWSER='google chrome' react-scripts start" in the scriptssection of your package.json.

Then run npm chrome.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.