mermaid-js / mermaid-cli

Command line tool for the Mermaid library
MIT License
2.48k stars 234 forks source link

When using from GitLab CI : error command not found #395

Closed Sulquendi closed 2 years ago

Sulquendi commented 2 years ago

I am using mermaid-cli in a gitlab CI pipeline,

so far my .gitlab.yaml file looks like this :

image: node:17.3.0
  before_script:
    - apt-get update
    - apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libnss3 lsb-release xdg-utils wget libgbm-dev     # puppeteer
    - npm install -g mdpdf 
    - npm install -g markdown-toc
    - npm install mermaid     # needs to be installed or not ?
    - npm install @mermaid-js/mermaid-cli
  script:
    # Adding the TOC to the md file
    - markdown-toc -i README.md
    # Converting mermaid md declaration to SVGs
    - mmdc -i README.md -o README-MER.md

This ends up with the following error :

/scripts-225629-47038994/step_script: line 163: mmdc: command not found

aloisklink commented 2 years ago

- npm install mermaid # needs to be installed or not ?

Mermaid doesn't need to be installed, it's included as part of @mermaid-js/mermaid-cli.

mmdc -i README.md -o README-MER.md

Try using the npx command instead:

npx --package=@mermaid-js/mermaid-cli mmdc -i README.md -o README-MER.md

npm install @mermaid-js/mermaid-cli usually installs mmdc into node_modules/.bin/mmdc, which probably isn't in your PATH environment variable.

Sulquendi commented 2 years ago

Thank you, the npx command line did the job !

MindaugasLaganeckas commented 2 years ago

@Sulquendi as it says in mermaid-cli readme, the path to access mermaid-cli after installing locally is ./node_modules/.bin/mmdc -h