Require ES Modules as an Empty Object.
A workaround for "Error [ERR_REQUIRE_ESM]: require() of ES Module not supported."
Intercepts failing require(NAME_OF_ES_MODULE)
calls and returns {}
.
npm install require-esm-as-empty-object
// app.js
const lru = require("quick-lru"); // an ES Module
console.log(lru);
{}
...
node -r require-esm-as-empty-object app.js
// app.js
// place at top of file before requiring an ES Module
require("require-esm-as-empty-object");
const lru = require("quick-lru");
...
node app.js