mermaid-js / mermaid-cli

Command line tool for the Mermaid library
MIT License
2.2k stars 207 forks source link

SyntaxError: The requested module `@mermaid-js/mermaid-cli` does not provide an export named 'run' (via SyntaxError) #669

Closed pdaoust closed 3 months ago

pdaoust commented 3 months ago

Describe the bug

It seems that the Node package doesn't export anything. Using the code example in the readme for using the Node.JS API, I just get errors like SyntaxError: The requested module@mermaid-js/mermaid-clidoes not provide an export named 'run' (via SyntaxError). If I try to import the module's default export, I get an empty object.

To Reproduce Steps to reproduce the behavior:

  1. Create a JavaScript file.
  2. Try to import any of the four exports provided in the Node.JS API
    import { run, renderMermaid } from "@mermaid-js/mermaid-cli";
  3. Try to run the file with Node.JS.
  4. Witness the aforementioned error.

Expected behavior

Availability of the five exports run, renderMermaid, cli, error, and the deprecated parseMMD when attempting to import @mermaid-js/mermaid-cli as an ES6 module.

Screenshots

image

Desktop:

Smartphone:

n/a

Additional context

My project is set up as an ES6 module, and all other imports of other NPM and internal modules work fine. The project is an 11ty-based static site generator, and I think 11ty might insinuate itself into the module loading pipeline somehow.

pdaoust commented 3 months ago

I'm not entirely sure what i was doing wrong the other day... I bashed my head against this and then retried the statement that I thought I'd started out with, and... it works. Closing. 🤷🏼‍♂️