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

Client does not start #572

Closed
tensionhead opened this issue Jul 25, 2023 · 4 comments
Closed

Client does not start #572

tensionhead opened this issue Jul 25, 2023 · 4 comments

Comments

@tensionhead
Copy link

Describe the bug
After global (or local) installation with npm, hitting mmdc in the terminal gives:

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

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

To Reproduce
Steps to reproduce the behavior:

  1. Install the mermaid client via npm install -g @mermaid-js/mermaid-cli
  2. run the mmdc client in a terminal

Desktop :

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.

@KSR-Yasuda
Copy link

Perhaps are you using Node.js < 14.x ?
Optional chaining (?.) syntax is supported from Node v14.

@tensionhead
Copy link
Author

tensionhead commented Jul 26, 2023

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'

@tensionhead
Copy link
Author

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 🚀

@aloisklink
Copy link
Member

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

"node": "^14.13 || >=16.0"
, 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!

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

No branches or pull requests

3 participants