简体   繁体   中英

create-react-app "Failed to compile" on start up

I am getting the following error when using npm start to open create-react-app. I'm new to React and I have had no problems the past few days doing the command line to make a new app.

I have tried npx start, npm start and installed npm again for the updated version.

Failed to compile
./src/index.css (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-3-1!./node_modules/postcss-loader/src??postcss!./src/index.css)
BrowserslistError: Unknown browser query `android all`. Maybe you are using old Browserslist or made typo in query.
    at Array.reduce (<anonymous>)
    at Array.some (<anonymous>)
    at Array.filter (<anonymous>)

It is a new bug in BrowserList.

There are new reports on this both in create-react-app: https://github.com/facebook/create-react-app/issues/7239

and in browserlist: https://github.com/browserslist/browserslist/issues/382#issuecomment-502991170

As suggested by John Forbes below the workaround given on the github issue is to change the browserslist entry in package.json to

"browserslist": []

This will build and run the project.

As proper temporal solution till bug fixing: add to package.json this:

  "resolutions": {
    "browserslist": "4.6.2",
    "caniuse-lite": "1.0.30000974"
  },

At the moment you can try this and wait for further fix

"browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [  
    ]
  }

I can confirm that forcing a yarn resolution for caniuse-lite@1.0.30000974 fixes the error. It must be an issue with the latest caniuse-lite@1.0.30000975 release.

temporary solution:

In package.json add

"resolutions": { "browserslist": "4.6.2", "caniuse-lite": "1.0.30000974" },

This method solved my problem.

I tried updating the browserlist and then did this.

  1. Delete this part in package.json
    "browserslist": {
        "production": [
          ">0.2%",
          "not dead",
          "not op_mini all"
        ],
  1. And run npm start

  2. It will ask for yes or no, give yes

Solved!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM