You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error [ERR_REQUIRE_ESM]: require() of ES Module "xxxx" is not suppored #3030
$ node webrequests.js
/Users/liuxg/nodejs/nodejs-logs/webrequests.js:315
undefined
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/liuxg/nodejs/node_modules/got/dist/source/index.js from /Users/liuxg/nodejs/nodejs-logs/webrequests.js not supported.
Instead change the require of index.js in /Users/liuxg/nodejs/nodejs-logs/webrequests.js to a dynamic import() which is available in all CommonJS modules.
at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at Object.<anonymous> (/Users/liuxg/nodejs/nodejs-logs/webrequests.js:1:13) {
code: 'ERR_REQUIRE_ESM'
}
Node.js v22.4.1
It seems that Got depends on diffrent versions, and it usage is also different. It would be good to speifiy its Node.js and Got package versions. Also, it can be worked around with the following code:
import got from 'got';
However, we need to rename the script extension to .mjs. I am using the following versions:
Activity