How to disable open browser in CRA? How to disable open browser in CRA? reactjs reactjs

How to disable open browser in CRA?


Create .env file in the root directory where your package.json file resides. And add the following:

BROWSER=none

Now run npm start.

Hope it helps :)


Add BROWSER=none to your npm start script in your package.json file, like this:

"scripts": {  "start": "BROWSER=none react-scripts start",  "build": "react-scripts build",  "test": "react-scripts test",  "eject": "react-scripts eject"},

Check out the CRA documentation for more configuration and environment variable options:

https://create-react-app.dev/docs/advanced-configuration/


Update/Troubleshooting:

In case you're having a 'BROWSER' is not recognized as an internal or external command, operable program or batch file error: do an npm install of cross-env:

npm install --save cross-env

Then, add cross-env BROWSER=none to your start script

"start": "cross-env BROWSER=none react-scripts start",