Object doesn't support property or method 'entries' - error in IE11
Asked Answered
C

2

9

I am working on a react app bootstrapped using create-react-app and it works perfectly in Chrome but I cannot get it to work in IE11.

Upon launching the app, I am getting the following error from the console:

Object doesn't support property or method 'entries'

I have spent hours trawling Google trying to find a solution and none of the recommended ones work.

Things I have tried:

  • importing react-app-polyfill/ie11 and react-app-polyfill/stable at the top of index.js
  • importing core-js/es/object/entries and core-js/features/object/entries at the top of index.js
  • Adding the following to index.js:
if (!Object.entries) {
  Object.entries = function( obj ){
    var ownProps = Object.keys( obj ),
        i = ownProps.length,
        resArray = new Array(i); // preallocate the Array
    while (i--)
      resArray[i] = [ownProps[i], obj[ownProps[i]]];

    return resArray;
  };
}

package.json:

{
  "name": "ceas-ui",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "auth0-js": "^9.8.2",
    "bootstrap": "^4.1.3",
    "core-js": "^3.6.4",
    "env-cmd": "^8.0.2",
    "joi-browser": "^13.4.0",
    "react": "^16.12.0",
    "react-app-polyfill": "^1.0.6",
    "react-bootstrap": "^1.0.0-beta.16",
    "react-dom": "^16.12.0",
    "react-loader-spinner": "^2.3.0",
    "react-modal": "^3.8.1",
    "react-router-bootstrap": "^0.25.0",
    "react-router-dom": "^5.1.2",
    "react-scripts": "^3.3.1",
    "react-slidedown": "^2.4.5",
    "react-toastify": "^4.5.2",
    "styled-components": "^5.0.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "test": "cls && react-scripts test --coverage --env=jsdom",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browser": {
    "joi": "joi-browser"
  },
  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-core": "^6.26.3",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "babel-preset-stage-0": "^6.24.1",
    "chai": "^4.2.0",
    "enzyme": "^3.9.0",
    "enzyme-adapter-react-16": "^1.9.0",
    "jsdom": "^13.2.0",
    "mocha": "^6.0.0",
    "react-test-renderer": "^16.8.2",
    "rimraf": "^2.6.3"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all",
      "ie 11"
    ],
    "development": [
      ">0.2%",
      "not dead",
      "not op_mini all",
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version",
      "ie 11"
    ]
  }
}

References:

Caramelize answered 5/2, 2020 at 15:34 Comment(1)
This sounds like an issue with this particular version of create-react-app as per the GitHub issue you've referenced. Perhaps downgrading to an older version until this gets resolved would be one of the options here.Bill
B
6

You can downgrade your react-scripts version. In your package.json , alter to "react-scripts": "3.2.0".

Take a look at https://github.com/facebook/create-react-app/issues/8405.

Biogeochemistry answered 6/2, 2020 at 7:49 Comment(1)
Thanks - this worked. Also had to add and import unorm into index.js to fix error Object doesn't support property or method 'entries'Caramelize
P
2

It seems to be an issue with react-scripts version 3.3.0 and higher. You could find many issue reports in GitHub, for example: github.com/facebook/create-react-app/issues/8197, github.com/facebook/create-react-app/issues/8195.

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.

Paraformaldehyde answered 6/2, 2020 at 8:7 Comment(1)
Thanks, this worked. I've accepted the other guy's answer purely based on timings.Caramelize

© 2022 - 2024 — McMap. All rights reserved.