我只是用
const fetch = require('node-fetch')
Run Code Online (Sandbox Code Playgroud)
我得到
Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\Alex\Desktop\rollbot\node_modules\node-fetch\src\index.js from C:\Users\Alex\Desktop\rollbot\index.js not supported.
Instead change the require of C:\Users\Alex\Desktop\rollbot\node_modules\node-fetch\src\index.js in C:\Users\Alex\Desktop\rollbot\index.js to a
dynamic import() which is available in all CommonJS modules.
{
code: 'ERR_REQUIRE_ESM'
}
Run Code Online (Sandbox Code Playgroud)
我的所有其他包都可以工作,只有 node-fetch 可以做到这一点。为了使用node-fetch,我应该做什么?