Skip to content Skip to sidebar Skip to footer

Getting Object Doesn't Support Property Or Method 'entries' Error Even When I Am Adding Polyfill

I am trying to load my web application on IE11 with the following browserslist configuration in package.json 'browserslist': { 'production': [ '>0.2%', 'not dead', 'no

Solution 1:

I tried installing yarn add core-js but when I try to do import 'core-js/es7/object'; the build fails saying the module does not exist. What should I do here? What is it that I am missing?

Perhaps the issue is related to the core-js version. In my react application, it using core-js@3.0.1 version, it doesn't contain the es7 folder, and if I using the Object.entries() method, it works well in IE11 (not add polyfill, perhaps it already add the object reference).

enter image description here

Besides, I also checked my another application, it using the core-js 2.6.1 version, and we can see the core-js folder contain es7 package, you could also check the core-js version:

enter image description here

Try to refer this link to update core-js version:

Besides, you could also add the following script in the header of Index.html. It also works well in IE11 browser.

<script>if (!Object.entries) {
      Object.entries = function( obj ){
        var ownProps = Object.keys( obj ),
            i = ownProps.length,
            resArray = newArray(i); // preallocate the Arraywhile (i--)
          resArray[i] = [ownProps[i], obj[ownProps[i]]];

        return resArray;
      };
    }
    </script>

Post a Comment for "Getting Object Doesn't Support Property Or Method 'entries' Error Even When I Am Adding Polyfill"