问题
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