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

Solution 1:

The current version of node-fetch is ONLY compatible with an ESM import (using import), not from CommonJS modules using require().

You have these choices to fix:

  1. Switch your project to an ESM module and load it with import fetch from 'node-fetch';.

  2. In a very recent version of nodejs, you can dynamically import an ESM module into a CommonJS module using let fetch = await import('node-fetch').

  3. Use the v2 version of node-fetch that still supports being loaded with require() as explained here in the doc.