markdown-magic
markdown-magic copied to clipboard
BUG: doctoc breaks md-magic
Tested with npm, yarn, pnpm, global or local installation. With node 14/16/17 and md-magic latest and older 2.5.2.
Seems like [email protected] dropped CJS support.
internal/modules/cjs/loader.js:948
throw new ERR_REQUIRE_ESM(filename);
^
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/ju/Library/pnpm/global/5/.pnpm/@[email protected]/node_modules/@technote-space/doctoc/dist/index.mjs
at new NodeError (internal/errors.js:322:7)
at Module.load (internal/modules/cjs/loader.js:948:11)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.<anonymous> (/Users/ju/Library/pnpm/global/5/.pnpm/[email protected]/node_modules/markdown-magic/lib/transforms/toc.js:1:23)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12) {
code: 'ERR_REQUIRE_ESM'
}
This broke me as well, see https://github.com/technote-space/doctoc/pull/73#issuecomment-1163919622 / https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/runs/7013732772?check_suite_focus=true
Just updated:
pnpm i -g markdown-magic@latest
- markdown-magic 2.5.2
+ markdown-magic 2.6.0
Result:
➜ astro git:(master) md-magic --path '**/*.md'
node:internal/modules/cjs/loader:973
throw new ERR_REQUIRE_ESM(filename, true);
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/ju/Library/pnpm/global/5/.pnpm/@[email protected]/node_modules/@technote-space/doctoc/dist/index.mjs not supported.
Instead change the require of /Users/ju/Library/pnpm/global/5/.pnpm/@[email protected]/node_modules/@technote-space/doctoc/dist/index.mjs to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/Users/ju/Library/pnpm/global/5/.pnpm/[email protected]/node_modules/markdown-magic/lib/transforms/toc.js:1:23)
at Object.<anonymous> (/Users/ju/Library/pnpm/global/5/.pnpm/[email protected]/node_modules/markdown-magic/lib/transforms/index.js:4:13)
at Object.<anonymous> (/Users/ju/Library/pnpm/global/5/.pnpm/[email protected]/node_modules/markdown-magic/lib/processFile.js:5:20)
at Object.<anonymous> (/Users/ju/Library/pnpm/global/5/.pnpm/[email protected]/node_modules/markdown-magic/index.js:2:21)
at Object.<anonymous> (/Users/ju/Library/pnpm/global/5/.pnpm/[email protected]/node_modules/markdown-magic/cli.js:5:23) {
code: 'ERR_REQUIRE_ESM'
}
Node.js v17.9.0
Opened a PR, going to need some help through. You can perform the change locally in your node_modules folder to generate a README, but its not a permanent fix obviously.
Locked the dep to older version here https://github.com/DavidWells/markdown-magic/pull/65
Released via [email protected]
Thanks for the report