The node-fetch
latest version doesn’t use the require()
syntax to import the package. You need to go to your package.json
and type
{
"type": "module",
}
to use the import
syntax and import node-fetch
, but then you can’t use require
for any other packages. You need to work with import
statement only.
Or you can use other packages, such as Got or Axios, which can be imported by the require()
syntax.