我正在尝试运行这个脚本
const fetch = require('node-fetch');
function test() {
fetch('https://google.com')
.then(res => res.text())
.then(text => console.log(text))
}
test();
Run Code Online (Sandbox Code Playgroud)
但我收到这个错误
该表达式不可调用。类型 'typeof import("(...)/node_modules/node-fetch/@types/index")' 没有调用签名.ts(2349)
虽然当我使用 import 时它可以工作
import fetch from 'node-fetch';
Run Code Online (Sandbox Code Playgroud)
为什么以及如何解决它?