ERR_REQUIRE_ESM on revolt.js 6.0.0-rc16 #13

Closed
opened 2026-02-16 12:26:46 -05:00 by yindo · 1 comment
Owner

Originally created by @WUGqnwvMQPzl on GitHub (Apr 27, 2022).

Seems latest 6.0.0 RC have some issues with ES Module, I tried using revolt.js on CommonJS and ESM and it throws same ERR_REQUIRE_ESM.

The last version that still works for me is 6.0.0-rc13.

Environment

  • OS: Arch Linux
  • Node.js Version: v16.15.0

Error output on CommonJS

/home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/websocket/client.js:27
const exponential_backoff_1 = require("@insertish/exponential-backoff");
                              ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/<username>/Documents/node-sandbox/node_modules/@insertish/exponential-backoff/dist/backoff.js from /home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/websocket/client.js not supported.
Instead change the require of backoff.js in /home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/websocket/client.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/websocket/client.js:27:31)
    at Object.<anonymous> (/home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/Client.js:26:18)
    at Object.<anonymous> (/home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/index.js:36:14)
    at Object.<anonymous> (/home/<username>/Documents/node-sandbox/rtest.js:3:20) {
  code: 'ERR_REQUIRE_ESM'
}

Error output on ESM

(node:36817) ExperimentalWarning: The Node.js specifier resolution flag is experimental. It could change or be removed at any time.
(Use `node --trace-warnings ...` to show where the warning was created)
/home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/websocket/client.js:27
const exponential_backoff_1 = require("@insertish/exponential-backoff");
                              ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/<username>/Documents/node-sandbox/node_modules/@insertish/exponential-backoff/dist/backoff.js from /home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/websocket/client.js not supported.
Instead change the require of backoff.js in /home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/websocket/client.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/websocket/client.js:27:31)
    at Object.<anonymous> (/home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/Client.js:26:18)
    at Object.<anonymous> (/home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/index.js:36:14)
    at async Promise.all (index 0) {
  code: 'ERR_REQUIRE_ESM'
}
Originally created by @WUGqnwvMQPzl on GitHub (Apr 27, 2022). Seems latest 6.0.0 RC have some issues with ES Module, I tried using revolt.js on CommonJS and ESM and it throws same ERR_REQUIRE_ESM. The last version that still works for me is 6.0.0-rc13. ### Environment - OS: Arch Linux - Node.js Version: v16.15.0 ### Error output on CommonJS ``` /home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/websocket/client.js:27 const exponential_backoff_1 = require("@insertish/exponential-backoff"); ^ Error [ERR_REQUIRE_ESM]: require() of ES Module /home/<username>/Documents/node-sandbox/node_modules/@insertish/exponential-backoff/dist/backoff.js from /home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/websocket/client.js not supported. Instead change the require of backoff.js in /home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/websocket/client.js to a dynamic import() which is available in all CommonJS modules. at Object.<anonymous> (/home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/websocket/client.js:27:31) at Object.<anonymous> (/home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/Client.js:26:18) at Object.<anonymous> (/home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/index.js:36:14) at Object.<anonymous> (/home/<username>/Documents/node-sandbox/rtest.js:3:20) { code: 'ERR_REQUIRE_ESM' } ``` ### Error output on ESM ``` (node:36817) ExperimentalWarning: The Node.js specifier resolution flag is experimental. It could change or be removed at any time. (Use `node --trace-warnings ...` to show where the warning was created) /home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/websocket/client.js:27 const exponential_backoff_1 = require("@insertish/exponential-backoff"); ^ Error [ERR_REQUIRE_ESM]: require() of ES Module /home/<username>/Documents/node-sandbox/node_modules/@insertish/exponential-backoff/dist/backoff.js from /home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/websocket/client.js not supported. Instead change the require of backoff.js in /home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/websocket/client.js to a dynamic import() which is available in all CommonJS modules. at Object.<anonymous> (/home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/websocket/client.js:27:31) at Object.<anonymous> (/home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/Client.js:26:18) at Object.<anonymous> (/home/<username>/Documents/node-sandbox/node_modules/revolt.js/dist/index.js:36:14) at async Promise.all (index 0) { code: 'ERR_REQUIRE_ESM' } ```
yindo closed this issue 2026-02-16 12:26:46 -05:00
Author
Owner

@insertish commented on GitHub (Apr 27, 2022):

Update to 6.0.0-rc.17.

@insertish commented on GitHub (Apr 27, 2022): Update to `6.0.0-rc.17`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: stoatchat/javascript-client-sdk#13