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

18 Replies, 990 Views

Hmm, sounds like an ESM vs CommonJS issue. If you’re set on using `import from node-fetch`, you’ll need to enable ESM in your project. Add `"type": "module"` to your package.json, and make sure your import statement looks like `import fetch from 'node-fetch'`.

If that doesn’t work, maybe try using `node --experimental-modules` to force ESM support. It’s a bit of a hassle, but it should get you going.

Messages In This Thread



Users browsing this thread: 1 Guest(s)