I want to get data from API and show it. I use node-fetch and express. Node-fetch is not supported 'require'. Therefore, I use import fetch from 'node-fetch'. For this, I added "type": "module" in package.json. I get an error when I try to add express. I tried const app = require('express')(); I get ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and 'C:\Users\name\Desktop\homework\package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///C:/Users/tahan/Desktop/bcfm_case/case.js:4:13 error.
I tried import * as app from 'express' . I get app.get is not a function.
How to use node-fetch and express at the same time?