DEV Community

Discussion on: The [require] module of [nodejs] doesn't operate. I need some help.

Collapse
 
vonheikemen profile image
Heiker • Edited

Looks like the latest version of node-fetch changed to ES modules by default. You have two choices.

1 - Convert your project to ES modules by adding "type": "module" in your package.json. And then import using this syntax:

import fetch from 'node-fetch';
Enter fullscreen mode Exit fullscreen mode

2 - Uninstall the current version of node-fetch and install version 2 with: npm install node-fetch@2.

Collapse
 
airsplit profile image
airsplit • Edited

The problem that has not been solved for two days has been solved thanks to you. Take care of COVID-19 and have a nice day.
Alt text of image