ESM support breaks on plain Node.js
Author: binyaminCreated Mar 19, 2026Updated Mar 19, 2026
Labelsbug
What happened?
Here's the error log:
import { Node } from '@markdoc/markdoc';
^^^^
SyntaxError: Named export 'Node' not found. The requested module '@markdoc/markdoc' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from '@markdoc/markdoc';
const { Node } = pkg;
at #asyncInstantiate (node:internal/modules/esm/module_job:302:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:405:5)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:660:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5)
Node.js v24.12.0To reproduce
Given the following 2 files, run node index.js
// package.json
{
"type": "module",
"dependencies": {
"@markdoc/markdoc": "^0.5.6"
}
}// index.js
import { Node } from '@markdoc/markdoc';
console.dir(Node);Version
0.5.6
Additional context
This lib uses the non-standard "module" field in the package.json for ESM support. Node.js has adopted the "exports" field, which is more robust. According to the esbuild docs, the "module" field comes from an old proposal for integrating ESM into Node.js.
Source: markdoc/markdoc