We're unable to detect target browsers. react app

Updated at 07-Nov-2022, By samar

We're unable to detect target browsers. react app

You have to add browserslist in the package.json file to avoid the error: We're unable to detect target browsers. react app.

You have to add below code in package.json file of react app.

"browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
}

Your code will look like below after adding the code in it.

{
  "name": "react-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "cra-template": "1.2.0",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-scripts": "^4.0.3"
  },
  "scripts": {
    "start": "react-scripts start",
    "test": "react-scripts test",
    "build": "react-scripts build",
    "eject": "react-scripts eject"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Now you can run the npm start command in the terminal to run the app.

npm start