Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React app is not working in IE 11 browser

I have seen a lot of similar questions here and I have tried all the ways but I have no idea why still not showing anything.

  1. npm install react-app-polyfill

  2. I added "ie 11" to production and development array in package.json

  3. Add this two-line import "react-app-polyfill/ie11"; import "react-app-polyfill/stable"; to top of index.js

  4. delete .cache folder inside node_modules

  5. Restart App

But still not showing anything in ie 11.

Here is my package.json

{
  "name": "firealarm",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.3",
    "@testing-library/user-event": "^7.1.2",
    "antd": "^3.26.2",
    "axios": "^0.19.0",
    "core-js": "^3.6.1",
    "cors": "^2.8.5",
    "jspdf": "^1.5.3",
    "jspdf-autotable": "^3.2.11",
    "react": "^16.12.0",
    "react-app-polyfill": "^1.0.5",
    "react-dom": "^16.12.0",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.3.0"
  },
  "scripts": {
    "start": "set PORT=3006 && react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      "ie 11",
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "ie 11",
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

I even remove the node_modules folder and install npm again but still not working.

Update

I got two error message in IE 11.

SCRIPT5022: SyntaxError
File: 0.chunk.js, Line: 176128, Column: 38

And

SCRIPT5022: The error you provided does not contain a stack trace.
File: 0.chunk.js, Line: 205780, Column: 64

.

like image 955
Loran Avatar asked Dec 27 '19 08:12

Loran


2 Answers

What is your react-scripts version? It seems an issue with react-scripts version 3.3.0. You could find the issue report in GitHub: issue 1, issue 2.

It can still work with [email protected]. You could try to revert back to 3.2.0 as a workaround. Please also remember to delete .cache folder in node_modules and delete IE browser cache then try again.

like image 75
Yu Zhou Avatar answered Oct 18 '22 01:10

Yu Zhou


Go to > /node_modules/react-dev-utils/webpackHotDevClient.js:60; add slashes: true

Below is the code sample

{
// Connect to WebpackDevServer via a socket.
var connection = new WebSocket(
  url.format({
    protocol: window.location.protocol === 'https:' ? 'wss' : 'ws',
    hostname: window.location.hostname,
    port: window.location.port,
    //Hardcoded in WebpackDevServer
    pathname: '/sockjs-node',
    slashes: true,
  })
);
}
like image 21
Satish Avatar answered Oct 18 '22 02:10

Satish