Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing this package leads to ERR_REQUIRE_ESM error. #6

Closed
totenn opened this issue Dec 17, 2019 · 1 comment
Closed

Importing this package leads to ERR_REQUIRE_ESM error. #6

totenn opened this issue Dec 17, 2019 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@totenn
Copy link

totenn commented Dec 17, 2019

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.

@manastalukdar manastalukdar self-assigned this Dec 17, 2019
@manastalukdar manastalukdar added this to the v0.1.3 milestone Dec 17, 2019
@manastalukdar manastalukdar added the bug Something isn't working label Dec 17, 2019
manastalukdar pushed a commit that referenced this issue Dec 18, 2019
Bumped version to 0.1.3.
@manastalukdar
Copy link
Owner

Fixed in v0.1.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants