0.0.1 • Published 2 years ago
require-esm-as-empty-object v0.0.1
require-esm-as-empty-object
Require ES Modules as an Empty Object.
A workaround for "Error ERR_REQUIRE_ESM: require() of ES Module not supported."
how does it work?
Intercepts failing require(NAME_OF_ES_MODULE)
calls and returns {}
.
usage
using r flag
// app.js
const lru = require("quick-lru"); // an ES Module
console.log(lru);
{}
...
node -r require-esm-as-empty-object app.js
placing at top of file
// 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
0.0.1
2 years ago