'node-fetch@3 Not support in nestjs because it is ESM

I can't use the package "node-fetch@3". I just import it and my console will log the error:

const node_fetch_1 = require("node-fetch");
                     ^
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/control-panel-nest2/node_modules/node-fetch/src/index.js from /home/control-panel-nest2/dist/bimwize/document.service.js not supported.
Instead change the require of index.js in /home/control-panel-nest2/dist/bimwize/document.service.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/home/control-panel-nest2/dist/bimwize/document.service.js:19:22)
    at Object.<anonymous> (/home/control-panel-nest2/dist/bimwize/bimwize.module.js:14:28)
    at Object.<anonymous> (/home/control-panel-nest2/dist/user/user.module.js:11:26)
    at Object.<anonymous> (/home/control-panel-nest2/dist/app.module.js:17:23)
    at Object.<anonymous> (/home/control-panel-nest2/dist/main.js:6:22)

I know what happend. node-fetch@3 only support esm but not commonjs and nestjs will compile all my import to require.

I don't know how to fix this problem. I have try to use node-fetch@2, but node-fetch@2 missing some of the feature I wanted.



Solution 1:[1]

Nestjs provide HTTP Module. Here is the doc url: https://docs.nestjs.com/techniques/http-module

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ???