Craft By Zen

Curation  /  The Stream  /  Running ESM on Node REPL

Running ESM on Node REPL

Published

d3 v7 is packaged as ESM only. That made it difficult to use in the Node.js REPL. From this StackOverflow thread, I found a solution.

let d3;
import("d3").then((module) => {
  d3 = module;
});
// Then you can use d3 anywhere once the promise is resolved.