Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node-fetch incompatibility with latest CommonJS modules' require() #32

Open
jishanshaikh4 opened this issue May 29, 2022 · 0 comments
Open

Comments

@jishanshaikh4
Copy link

Latest node-fetch is only compatible with ESM modules. Reverting to old node-fetch would work as long as other vulnerable spots are covered.

Error:

> [email protected] start
> node app.js

Gitwar/utils/fetchTrending.js:2
const fetch = require("node-fetch");
              ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Gitwar/node_modules/node-fetch/src/index.js from /Gitwar/utils/fetchTrending.js not supported.
Instead change the require of index.js in /Gitwar/utils/fetchTrending.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Gitwar/utils/fetchTrending.js:2:15)
    at Object.<anonymous> (/Gitwar/routes/top.js:6:31)
    at Object.<anonymous> (/Gitwar/app.js:40:19) {
  code: 'ERR_REQUIRE_ESM'
}

Reverting to older version of node-fetch should do the job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant