Default create-react-app does not work in IE despite polyfills and browser list

人盡茶涼 提交于 2021-02-05 08:32:57

问题


Am on the simple quest to get create-react-app working in IE 11. I am working from Mac OS X and I cannot get IE 11 working either through VirtualBox or through a Windows computer (both in dev and production mode).

I have investigated this thoroughly, and tried the following:

  • Adjusted package.json as per the below, then (i) removed node_modules/.cache, then when that didn't work, (ii) removed node_modules

"browserslist": {
    "production": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version",
      "ie 11"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version",
      "ie 11"
    ]
  }
  • Added these two lines to the top of my index.js file:

import 'react-app-polyfill/ie11';
import 'react-app-polyfill/stable';
  • Installed @babel/polyfill and inserted this line at the top of index.js

import "@babel/polyfill";

All of this is with the default app created by create-react-app. No luck, and all I get in IE is a completely blank screen with "React App" as the title. The F12 Developer tools give the below errors:

Any help on this greatly appreciated!


回答1:


Perhaps the issue is related to the react-scripts version, you are using react-scripts 3.3.0 and higher. You could check the package.json file to verify it.

There are some thread reports this error in GitHub, you could refer to them, for example: github.com/facebook/create-react-app/issues/8197, github.com/facebook/create-react-app/issues/8195.

As a workaround, you could try to downgrade the react-scripts version. As far as I know, it can still work with react-scripts@3.2.0.



来源:https://stackoverflow.com/questions/59784600/default-create-react-app-does-not-work-in-ie-despite-polyfills-and-browser-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!