Importing in Node.js: error “Must use import to load ES Module” [duplicate]

Use version 2:

npm install node-fetch@2

node-fetch from v3 is an ESM-only module – you are not able to import it with require().

If you cannot switch to ESM, please use v2 which remains compatible with CommonJS. Critical bug fixes will continue to be published for v2.

Leave a Comment