Error [ERR_REQUIRE_ESM]: require() of ES Module not supported [duplicate]

The node-fetch latest version doesn’t use the require() syntax to import the package. You need to go to your package.json and type { “type”: “module”, } to use the import syntax and import node-fetch, but then you can’t use require for any other packages. You need to work with import statement only. Or you can … Read more

Error: require() of ES modules is not supported when importing node-fetch

From the Upgrade Guide node-fetch was converted to be a ESM only package in version 3.0.0-beta.10. node-fetch is an ESM-only module – you are not able to import it with require. Alternatively, you can use the async import() function from CommonJS to load node-fetch asynchronously: // mod.cjs const fetch = (…args) => import(‘node-fetch’).then(({default: fetch}) => … Read more