The React project opens the Chrome browser by default and cancels opening the browser.

React cancels opening the browser by default every time the project is run.

In the package.json file, change "start": "node scripts/start.js" to set BROWSER=none && node scripts/start.js

  "scripts": {
    "start": "set BROWSER=none && node scripts/start.js",
    "build": "node scripts/build.js",
    "test": "node scripts/test.js"
  },

After running successfully, the browser will not be opened automatically. We need to copy the URL and open it in the browser.

The React project opens the Chrome browser by default

Set "start" in the package.json file: "set BROWSER=chrome&& node scripts/start.js",

  "scripts": {
   "start": "set BROWSER=chrome&& node scripts/start.js",
    "build": "node scripts/build.js",
    "test": "node scripts/test.js"
  },

After running the project, the chrome browser will automatically open

Note that there should be no space between chrome and &&, otherwise, the browser will not start.

When setting up, a space was added after chrome, and the chrome browser did not open when running the project.

Guess you like

Origin blog.csdn.net/Celester_best/article/details/129000259