Error code

Node.js ERR_REQUIRE_ESM

NODE.JSERR_REQUIRE_ESM
Runtime Error Code· An error code from a programming runtime or package manager, like Node.js or npm.

What it means

A CommonJS require() call attempted to load an ES module.

How to fix it

  1. Import the module using dynamic import() instead of require().
  2. Change the requiring file to use ESM by renaming it to .mjs or setting "type":"module".
  3. Check if the package offers a CommonJS build (often under /cjs or /lib).

Not affiliated with Node.js. Answer summarized from the manufacturer's manual linked above; consult that source for the authoritative procedure.