- Instant help with your JavaScript coding problems

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

Question:
How to solve the Error [ERR_REQUIRE_ESM]: require() of ES Module not supported?
Answer:
import fetch from "node-fetch";
Description:

More and more node.js modules are being converted to clean ESM modules like in case of node-fetch v3. This can result breaking changes which results in the following error message:

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

Using require to load an ES module is not supported because ES modules have asynchronous execution. Instead, use import() to load an ES module.

 

Reference:
Node.js require
Share "How to solve the Error [ERR_REQUIRE_ESM]: require() of ES Module not supported?"
Tags:
ERR_REQUIRE_ESM, require, ESM, ES module, node-fetch
Technical term:
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported