Importing into a non-ESM Node.js environment throws an error.
NotTimTam opened this issue ยท 2 comments
NotTimTam commented
Like the title says, importing into a non-ESM node module causes an error.
Here is my code:
const { marked } = require("marked");
const { gfmHeadingId } = require("marked-gfm-heading-id");
marked.use(
{
langPrefix: "",
mangle: false,
headerIds: false,
},
gfmHeadingId()
);
// ...
const convertedData = marked.parse(existingData);
Here is the output at runtime:
D:\Code\extrusive-test-env\extrusive.md\node_modules\marked-gfm-heading-id\lib\index.cjs:3
var GithubSlugger = require('github-slugger');
^
Error [ERR_REQUIRE_ESM]: require() of ES Module D:\Code\extrusive-test-env\extrusive.md\node_modules\github-slugger\index.js from D:\Code\extrusive-test-env\extrusive.md\node_modules\marked-gfm-heading-id\lib\index.cjs not supported.
Instead change the require of index.js in D:\Code\extrusive-test-env\extrusive.md\node_modules\marked-gfm-heading-id\lib\index.cjs to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (D:\Code\extrusive-test-env\extrusive.md\node_modules\marked-gfm-heading-id\lib\index.cjs:3:21)
at Object.<anonymous> (D:\Code\extrusive-test-env\extrusive.md\resources\scripts\build_app.js:6:26)
at Object.<anonymous> (D:\Code\extrusive-test-env\extrusive.md\index.js:6:19) {
code: 'ERR_REQUIRE_ESM'
}
Node.js v18.16.0
Let me know if you need more information.
github-actions commented
๐ This issue has been resolved in version 3.0.2 ๐
The release is available on:
Your semantic-release bot ๐ฆ๐
UziTech commented
Thanks for reporting this! ๐ฏ