Closed janihur closed 11 months ago
It sounds like you have some sort of permission error (maybe because you're using a Node.JS version installed via snap
?).
My recommendation is to use npx
(also known as npm exec
), with:
npx -p @mermaid-js/mermaid-cli mmdc --help
NPM will then automatically install and cache a version of @mermaid-js/mermaid-cli
for you, if it isn't already installed! That way you don't need sudo
permissions! Please see the Install locally part of the README.md for more info.
Hmm ... I have successfully used snap version of Node.js with other JavaScript software. Here the problem might be the puppeteer
module - trying to install puppeteer
only fails too. Maybe the module is not "snap Node.js-compatible"?
npx
is new to me. I'll check that (hopefully soon).
Here the problem might be the
puppeteer
module - trying to installpuppeteer
only fails too. Maybe the module is not "snap Node.js-compatible"?
You're right! It looks like puppeteer
fails to install properly if Node.js is installed via snap
, see https://github.com/puppeteer/puppeteer/issues/7725, https://github.com/puppeteer/puppeteer/issues/7383, and https://github.com/puppeteer/puppeteer/issues/7007.
Thanks for letting us know, since I've actually been recommending people to install Node.JS from snap
without knowing that Puppeteer won't install properly on it!
I'll close this as the bug is with the Puppeteer library (and/or with the snap
version of Node.JS), and not with us, but it looks like nobody in the Puppeteer library is working on.
If you can, please upvote the https://github.com/puppeteer/puppeteer/issues/7725 issue so that the puppeteer team is aware of the issue!
I was able to install and run mermaid-cli in Lubuntu 22.04 with the following steps.
Install node.js from NodeSource repository, see https://github.com/nodesource/distributions/blob/master/README.md#debian-and-ubuntu-based-distributions
node.js version:
$ which node
/usr/bin/node
$ node --version
v18.18.0
$ npm --version
9.8.1
mermaid-cli installs now succesfully globally:
$ sudo npm install -g @mermaid-js/mermaid-cli
However we're still missing Chromium:
$ mmdc -i example.mmd -o example.svg
Error: Could not find Chromium (rev. 1108766). This can occur if either
1. you did not perform an installation before running the script (e.g. `npm install`) or
2. your cache path is incorrectly configured (which is: /home/jani/.cache/puppeteer).
For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.
at ChromeLauncher.resolveExecutablePath (file:///usr/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/node/ProductLauncher.js:263:27)
at ChromeLauncher.executablePath (file:///usr/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/node/ChromeLauncher.js:176:25)
at ChromeLauncher.computeLaunchArguments (file:///usr/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/node/ChromeLauncher.js:93:37)
at async ChromeLauncher.launch (file:///usr/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/node/ProductLauncher.js:57:28)
at async run (file:///usr/lib/node_modules/@mermaid-js/mermaid-cli/src/index.js:404:19)
at async cli (file:///usr/lib/node_modules/@mermaid-js/mermaid-cli/src/index.js:184:3)
Download Chromium:
$ node /usr/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer/install.js
Downloading chromium r1108766 - 171.9 MB [====================] 100% 0.0s
Chromium (1108766) downloaded to /home/jani/.cache/puppeteer/chrome/linux-1108766
Now the mmdc
command works:
$ mmdc -i example.mmd -o example.svg
Generating single mermaid chart
$ ls -1 example.*
example.mmd
example.svg
Describe the bug I'm trying to install mermaid-cli in Lubuntu LTS 22.04 with
but the command fails:
To Reproduce Lubuntu version:
Node version, snap installation:
The installation command:
I don't have
/usr/local/lib/node_modules
created:The full log file: 2023-09-18T06_03_36_188Z-debug-0.log but here the end of the file that hopefully contains all the relevant information:
Expected behavior
I'm expecting the installation making
mmdc
command available.