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:
-
Switch your project to an ESM module and load it with
import fetch from 'node-fetch';. -
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'). -
Use the v2 version of
node-fetchthat still supports being loaded withrequire()as explained here in the doc.