Closed
Description
Problem Statement
Importing this module in node 13 leads to ERR_REQUIRE_ESM error.
Description
Seems to be related to this:
nodejs/node#29492
'require' is no longer allowed when "type":"module" is set in package.json.
Platform
Node v13.3.0
Expected behavior
No error occurs.
Observed behavior
The following error occurs:
(node:5061) Warning: require() of ES modules is not supported.
require() of ./node_modules/markdown-it-textual-uml/src/plantuml-parser.js from ./node_modules/markdown-it-textual-uml/src/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename plantuml-parser.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from ./node_modules/markdown-it-textual-uml/package.json.
internal/modules/cjs/loader.js:1163
throw new ERR_REQUIRE_ESM(filename);
^
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: ./node_modules/markdown-it-textual-uml/src/plantuml-parser.js
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1163:13)
at Module.load (internal/modules/cjs/loader.js:983:32)
at Function.Module._load (internal/modules/cjs/loader.js:891:14)
at Module.require (internal/modules/cjs/loader.js:1023:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (./markdown-it-textual-uml/src/index.cjs:3:24)
at Module._compile (internal/modules/cjs/loader.js:1128:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:983:32)
at Function.Module._load (internal/modules/cjs/loader.js:891:14) {
code: 'ERR_REQUIRE_ESM'
}
Steps to reproduce behavior
Import the package:
import MarkdownItTextualUml from 'markdown-it-textual-uml';
Run with node.
Other notes
This can be fixed by deleting the line
"type":"module"
from package.json.