mermaid-js / mermaid-cli

Command line tool for the Mermaid library
MIT License
2.23k stars 210 forks source link

Syntax Error in Mermaid-cli tool #651

Closed Breinich closed 4 months ago

Breinich commented 5 months ago

Describe the bug

Failed to generate svg files for the mermaid diagrams because of an internal js syntax error, the response:

file:///usr/local/lib/node_modules/@mermaid-js/mermaid-cli/src/index.js:262
      const svg = container.getElementsByTagName?.('svg')?.[0]
                                                 ^

SyntaxError: Unexpected token '.'
    at Loader.moduleStrategy (internal/modules/esm/translators.js:133:18)

To Reproduce

  1. Install the package with npm install -g @mermaid-js/mermaid-cli
  2. Run the command: mmdc -i Short.md -o Short_svg.md

Expected behavior

Generating an output md file and the according svg files

Screenshots

not applicable

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

Breinich commented 5 months ago

Turns out I had an old version of Nodejs installed, so this was the root cause.