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

Failing to generate an image from the state diagram #4

Closed
diegobernardes opened this issue May 20, 2020 · 6 comments
Closed

Failing to generate an image from the state diagram #4

diegobernardes opened this issue May 20, 2020 · 6 comments
Assignees
Labels
Inactive Mark for stale

Comments

@diegobernardes
Copy link

diegobernardes commented May 20, 2020

This is the error:

mmdc -i diagram.mmd -o diagram.png
(node:92883) UnhandledPromiseRejectionWarning: Error: Evaluation failed: Error: Parse error on line 1:
stateDiagram	s1: In
^
Expecting 'NEWLINE', 'SPACE', 'GRAPH', got 'ALPHA'
    at Yt.parseError (file:///Users/dbernardes/.asdf/installs/nodejs/13.8.0/.npm/lib/node_modules/mermaid.cli/mermaid.min.js:1:486512)
    at Yt.parse (file:///Users/dbernardes/.asdf/installs/nodejs/13.8.0/.npm/lib/node_modules/mermaid.cli/mermaid.min.js:1:487678)
    at Object.e.getClasses (file:///Users/dbernardes/.asdf/installs/nodejs/13.8.0/.npm/lib/node_modules/mermaid.cli/mermaid.min.js:1:749437)
    at Object.render (file:///Users/dbernardes/.asdf/installs/nodejs/13.8.0/.npm/lib/node_modules/mermaid.cli/mermaid.min.js:1:759998)
    at s (file:///Users/dbernardes/.asdf/installs/nodejs/13.8.0/.npm/lib/node_modules/mermaid.cli/mermaid.min.js:8:233)
    at Object.init (file:///Users/dbernardes/.asdf/installs/nodejs/13.8.0/.npm/lib/node_modules/mermaid.cli/mermaid.min.js:8:318)
    at __puppeteer_evaluation_script__:17:20
    at ExecutionContext._evaluateInternal (/Users/dbernardes/.asdf/installs/nodejs/13.8.0/.npm/lib/node_modules/mermaid.cli/node_modules/puppeteer/lib/ExecutionContext.js:122:13)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async ExecutionContext.evaluate (/Users/dbernardes/.asdf/installs/nodejs/13.8.0/.npm/lib/node_modules/mermaid.cli/node_modules/puppeteer/lib/ExecutionContext.js:48:12)
    at async ElementHandle.evaluate (/Users/dbernardes/.asdf/installs/nodejs/13.8.0/.npm/lib/node_modules/mermaid.cli/node_modules/puppeteer/lib/JSHandle.js:55:12)
    at async ElementHandle.$eval (/Users/dbernardes/.asdf/installs/nodejs/13.8.0/.npm/lib/node_modules/mermaid.cli/node_modules/puppeteer/lib/JSHandle.js:478:20)
  -- ASYNC --
    at ExecutionContext.<anonymous> (/Users/dbernardes/.asdf/installs/nodejs/13.8.0/.npm/lib/node_modules/mermaid.cli/node_modules/puppeteer/lib/helper.js:111:15)
    at ElementHandle.evaluate (/Users/dbernardes/.asdf/installs/nodejs/13.8.0/.npm/lib/node_modules/mermaid.cli/node_modules/puppeteer/lib/JSHandle.js:55:42)
    at ElementHandle.<anonymous> (/Users/dbernardes/.asdf/installs/nodejs/13.8.0/.npm/lib/node_modules/mermaid.cli/node_modules/puppeteer/lib/helper.js:112:23)
    at ElementHandle.$eval (/Users/dbernardes/.asdf/installs/nodejs/13.8.0/.npm/lib/node_modules/mermaid.cli/node_modules/puppeteer/lib/JSHandle.js:478:40)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
  -- ASYNC --
    at ElementHandle.<anonymous> (/Users/dbernardes/.asdf/installs/nodejs/13.8.0/.npm/lib/node_modules/mermaid.cli/node_modules/puppeteer/lib/helper.js:111:15)
    at DOMWorld.$eval (/Users/dbernardes/.asdf/installs/nodejs/13.8.0/.npm/lib/node_modules/mermaid.cli/node_modules/puppeteer/lib/DOMWorld.js:156:21)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
  -- ASYNC --
    at Frame.<anonymous> (/Users/dbernardes/.asdf/installs/nodejs/13.8.0/.npm/lib/node_modules/mermaid.cli/node_modules/puppeteer/lib/helper.js:111:15)
    at Page.$eval (/Users/dbernardes/.asdf/installs/nodejs/13.8.0/.npm/lib/node_modules/mermaid.cli/node_modules/puppeteer/lib/Page.js:347:29)
    at Page.<anonymous> (/Users/dbernardes/.asdf/installs/nodejs/13.8.0/.npm/lib/node_modules/mermaid.cli/node_modules/puppeteer/lib/helper.js:112:23)
    at /Users/dbernardes/.asdf/installs/nodejs/13.8.0/.npm/lib/node_modules/mermaid.cli/index.bundle.js:83:14
    at Generator.next (<anonymous>)
    at step (/Users/dbernardes/.asdf/installs/nodejs/13.8.0/.npm/lib/node_modules/mermaid.cli/index.bundle.js:4:191)
    at /Users/dbernardes/.asdf/installs/nodejs/13.8.0/.npm/lib/node_modules/mermaid.cli/index.bundle.js:4:361
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:92883) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:92883) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

The mermaid file:

stateDiagram
	s1: Input Queue
	s2: Function
	s3: Function Success
	s4: Function Fail
	s5: Notification Queue
	s6: Notification Queue Success
	s7: Notification Queue Fail

	[*] --> s1
	s1 --> s2
	s2 --> s3
	s2 --> s4
	s3 --> s5
	s4 --> s5
	s5 --> s6
	s5 --> s7
	s6 --> [*]
	s7 --> s1

But it's working fine at the web editor:
image

@LarryBattle
Copy link

LarryBattle commented Jun 3, 2020

I just tested out your file on "@mermaid-js/mermaid-cli": "^8.5.1-2" on Ubuntu and it generated the correct diagram without any errors.

The error in the stacktrace (stateDiagram s1: In) looks like mermaid-cli was unable to read the line breaks in the file.
Try recreating diagram.mmd in an different text editor on the same system then re-run your command. ./node_modules/.bin/mmdc -i diagram.mmd -o diagram.png

@diegobernardes
Copy link
Author

diegobernardes commented Jun 8, 2020

Still giving me an error. There is no hidden char at the file, look at the editor showing all the chars.

image

This editor is the VSCode. I've tried to use Vim as well, same problem.

@MindaugasLaganeckas
Copy link
Member

MindaugasLaganeckas commented Jun 26, 2020

Hey @diegobernardes, I have tried to reproduce the error you have reported without any luck. From the error message it seems clear, that there is something wrong with your input file. Anyhow, I have created a branch for your case. You can find your state file here: https://github.com/MindaugasLaganeckas/mermaid-cli/blob/issue/4/test/issue-4.mmd and the diagram, generated by mermaid-cli, here: https://github.com/MindaugasLaganeckas/mermaid-cli/suites/844280879/artifacts/9556201. The filename to look for is issue-4.mmd.svg. You are welcome to download the file issue-4.mmd AS IS, install the newest mermaid-cli (8.5.3) and generate the diagram yourself.

@MindaugasLaganeckas MindaugasLaganeckas self-assigned this Jun 26, 2020
@MindaugasLaganeckas MindaugasLaganeckas added the Inactive Mark for stale label Oct 25, 2020
@Kochise
Copy link

Kochise commented Nov 12, 2020

Got this (see attached picture)

state

Check this : #503

The old repo (v0.5.1) is not functional, use the new repo (v8.+). It's confusing, but 'mermaidjs' is not the same as 'mermaid-js'.

npm install -g mermaid.cli ---> fails (v0.5.1)
npm install -g @mermaid-js/mermaid-cli ---> works (v8.+)

@MindaugasLaganeckas
Copy link
Member

Cannot reproduce. No answer from the reporter.

@yannicschroeer
Copy link

I was able to reproduce this by using Node v16. Using Node v18 resolved this issue for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Inactive Mark for stale
Projects
None yet
Development

No branches or pull requests

5 participants