In all of the chessjs documentation, const chess = require('chess'); is used.
However, when I try to use this syntax, I get this error:
const Chess = require('chess');
^
Error [ERR_REQUIRE_ESM]: require() of ES Module is not supported.
Instead change the require of main.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> {
code: 'ERR_REQUIRE_ESM'
}
Is there a solution for this?
requiresome modules depending on an if statement in the middle of my index file, which you can't do with esm becauseimports have to be top-level only.await import()for those inline casesESMmodule in a CJS file