简体   繁体   中英

Array.prototype.flat() creates an error when building Gatsby site

When building, I get the following error:

WebpackError: TypeError: Object.entries(...).map(...).flat is not a function

I can gatsby deveop the app just fine, and all works as expected in the browser.

Any ideas on how to remedy this?

I'm not sure if this is ideal, but the only way I was able to fix this was by adding a polyfill and including it at the top of the offending file.

> yarn add array-flat-polyfill

// src/pages/page-with-error.js
import 'array-flat-polyfill';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM