Having trouble with import from node-fetch? How do I properly set it up in my project?

18 Replies, 768 Views

Yo, I feel your pain. Node 16 can be a bit picky with imports. If you’re getting a "module not found" error, it might be because node-fetch v3+ is ESM-only. Try downgrading to v2 with `npm install node-fetch@2` if you don’t wanna deal with ESM stuff.

Alternatively, you could switch to CommonJS with `const fetch = require('node-fetch')`. Just depends on how you wanna structure your project.

Messages In This Thread



Users browsing this thread: 1 Guest(s)