I'm working on a project that uses CommonJS modules instead of ES modules. When I try to require
the extension, I get an error.
> node src/js/toHtml.js
/Users/liam/,/programs/liam/0ty/src/js/toHtml.js:13
const markedKatex = require( 'marked-katex-extension' );
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/liam/,/programs/liam/0ty/node_modules/marked-katex-extension/src/index.js from /Users/liam/,/programs/liam/0ty/src/js/toHtml.js not supported.
Instead change the require of index.js in /Users/liam/,/programs/liam/0ty/src/js/toHtml.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/Users/liam/,/programs/liam/0ty/src/js/toHtml.js:13:21) {
code: 'ERR_REQUIRE_ESM'
}
I'm happy to use a dynamic import, but I thought I'd open up this issues since your README seems to indicate it's possible to use CommonJS require
. Does the README need to be updated to reflect the fact that you can't use CommonJS require
? Or am I doing something wrong? Thanks!