Closed tensionhead closed 1 year ago
Perhaps are you using Node.js < 14.x ?
Optional chaining (?.
) syntax is supported from Node v14.
Indeed, the standard Node.js installation from the Ubuntu software sources gives version v12.x
. Thanks, I am gonna check how to install a >= v14.x
version!
EDIT: Ok following this guide, I got Node.js 14.4 and npm 6.14.5 installed.
However, after re-installing the mermaid-cli I now get when starting the mmdc
client in the terminal:
internal/modules/run_main.js:54
internalBinding('errors').triggerUncaughtException(
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '/usr/local/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/chalk/source/node_modules/' imported from /usr/local/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/chalk/source/index.js
at packageMainResolve (internal/modules/esm/resolve.js:465:9)
at packageResolve (internal/modules/esm/resolve.js:607:14)
at moduleResolve (internal/modules/esm/resolve.js:659:14)
at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:752:11)
at Loader.resolve (internal/modules/esm/loader.js:97:40)
at Loader.getModuleJob (internal/modules/esm/loader.js:242:28)
at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:50:40)
at link (internal/modules/esm/module_job.js:49:36) {
code: 'ERR_MODULE_NOT_FOUND'
Ok I think I got it, using
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
then nvm install --lts
and finally npm install @mermaid-js/mermaid-cli
I got the client running! Node.js is now v18.17.0
and mmdc
works :rocket:
Yep, sorry, we only support Node v14.13 and up, and we'll soon have to drop Node v14 support, since it's no longer supported by the Node.JS team, and many of our dependencies are dropping support too.
It's listed in https://github.com/mermaid-js/mermaid-cli/blob/57f826263e52c7ff821372c1c3f3a811c36ff7bf/package.json#L13, so NPM should have printed a warning about it, but your NPM version might have been too old for this!
Node.js installation from the Ubuntu software sources
FYI, I would highly recommend not using the default Ubuntu apt repo for Node.JS. LTS Node.JS releases are only actively maintained by the Node.JS team for 2.5 years (see https://github.com/nodejs/release#release-schedule). Afterwards, you're relying on the Debian/Ubuntu team to fix security issues, but they generally struggle with backporting security fixes, since Node.JS is a very large project.
NVM is great if you're a developer, but since it's doesn't automatically update Node.JS, it's not great from a security standpoint.
If you're running Ubuntu, snap
or the NodeSource apt
repo are generally what I'd recommend using to install Node.JS, so that you'll get automatic updates!
Describe the bug After global (or local) installation with npm, hitting
mmdc
in the terminal gives:To Reproduce Steps to reproduce the behavior:
npm install -g @mermaid-js/mermaid-cli
mmdc
client in a terminalDesktop :
OS: Ubuntu 22.04
Additional context I also tried the alternative installation instructions, a local installation via npm yields the exact same error. Installation via
yarn
failed because of dependecy issues.