sindresorhus / file-type

Detect the file type of a Buffer/Uint8Array/ArrayBuffer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[ERR_REQUIRE_ESM] Error using webpack or babel

rafaelgdn opened this issue · comments

Anyone know how to fix this error?

require() of ES Module /Users/rafaeldecarvalho/dev/bgc/criminal/bgc-scrapers/node_modules/file-type/index.js from /Users/rafaeldecarvalho/dev/bgc/criminal/bgc-scrapers/.webpack/HealthsurveillanceCrawl/src/functions/crawl/healthsurveillance.js not supported.\n' + 'Instead change the require of index.js in /Users/rafaeldecarvalho/dev/bgc/criminal/bgc-scrapers/.webpack/HealthsurveillanceCrawl/src/functions/crawl/healthsurveillance.js to a dynamic import() which is available in all CommonJS modules.

I tried to import in a dynamic way like that:
const fileTypeDynamicImport = async () => { const fileType = await import("file-type"); return fileType; };

I tried to add some configs to babel to ignore dynamic import:
[ "@babel/preset-env", { "exclude": [ "proposal-dynamic-import" ] } ]

I dont know how to solve this. Any help?