emersonbottero / vitepress-plugin-mermaid

Add mermaid support for Vitepress
MIT License
95 stars 22 forks source link

Updating mermaid to 9.2.0 reported an error #24

Closed Charles7c closed 1 year ago

Charles7c commented 2 years ago

An error was reported at the console:

Uncaught SyntaxError: The requested module '/@fs/F:/Learn/02_Workspace/$个人站点/$个人知识库/charles7c.github.io/node_modules/.pnpm/dagre@0.8.5/node_modules/dagre/index.js?v=b2b200f6' does not provide an export named 'default' (at mermaid.core.mjs?v=b2b200f6:13:8)
emersonbottero commented 2 years ago

Do you have a repo to share?

Hyphon commented 2 years ago

same here, and repo link is: https://codesandbox.io/s/beautiful-river-lv65vx

Charles7c commented 2 years ago

Do you have a repo to share?

You can clone and then upgrade the version in package.json. https://github.com/Charles7c/charles7c.github.io

BasilaryGroup commented 1 year ago

I'm having the same problem with version 2.0.8 and 2.0.6. Using vitepress 1.0.0-alpha.29.

yayxs commented 1 year ago
mermaid.core.mjs?v=db61a261:13 Uncaught SyntaxError: The requested module '/@fs/电脑上项目的位置目录/node_modules/.pnpm/registry.npmmirror.com+dagre@0.8.5/node_modules/dagre/index.js?v=db61a261' does not provide an export named 'default' (at mermaid.core.mjs?v=db61a261:13:8)

how to use

我主要参考了文档的使用指南 Getting Started

pnpm i vitepress-plugin-mermaid mermaid -D

 "dependencies": {
    "vitepress": "1.0.0-alpha.29",
    "vue": "^3.2.45"
  },
  "devDependencies": {
    "mermaid": "^9.2.2",
    "vitepress-plugin-mermaid": "^2.0.8"
  }
import { defineConfig } from 'vitepress'
+ import { withMermaid } from 'vitepress-plugin-mermaid'
export default withMermaid(
  defineConfig({
    // my config
    mermaid: {
      // refer https://mermaid-js.github.io/mermaid/#/Setup for options
    }
  })
)

issue

我似乎遇到了上述类似的问题 I seem to be running into a similar problem to the above You can take a look at this repo

bojanrajh commented 1 year ago

Downgrading mermaid to 9.1.7 solves the issue. The first broken version is 9.2.0-rc2.

{
  "devDependencies": {
    "mermaid": "9.1.7",
    ...
  }
}
yayxs commented 1 year ago

@bojanrajh This works, thanks a lot

xu4wang commented 1 year ago

Downgrading mermaid to 9.1.7 solves the issue. The first broken version is 9.2.0-rc2.

{
  "devDependencies": {
    "mermaid": "9.1.7",
    ...
  }
}

Thanks for the info.. 9.1.7 works.

Seems 9.2 supports mindmap which 9.1.7 does not.
Still need to support the latest version of mermaid in a long run.

yayxs commented 1 year ago

Downgrading mermaid to 9.1.7 solves the issue. The first broken version is 9.2.0-rc2.

{
  "devDependencies": {
    "mermaid": "9.1.7",
    ...
  }
}

Thanks for the info.. 9.1.7 works.

Seems 9.2 supports mindmap which 9.1.7 does not. Still need to support the latest version of mermaid in a long run.


I tried it, the syntax of mindmap seems to be not working. Like: image

mindmap
Root
    A
      B
      C
ModyQyW commented 1 year ago

@yayxs mermaid v9.1.7 has no mindmap.

image
yayxs commented 1 year ago

@yayxs mermaid v9.1.7 has no mindmap.

image

Really, thanks

emersonbottero commented 1 year ago

I guess is the way mermaid is exporting the library after 9.2.2. can you try to add an vite config?

// docs/vite.config.ts or docs/vite.config.js
import { defineConfig } from "vite";

export default defineConfig({
  resolve: {
    alias: {
        "mermaid": "mermaid/dist/mermaid.esm.mjs",
    },
  },
});
Charles7c commented 1 year ago
// docs/vite.config.ts or docs/vite.config.js
import { defineConfig } from "vite";

export default defineConfig({
  resolve: {
    alias: {
        "mermaid": "mermaid/dist/mermaid.esm.mjs",
    },
  },
});

Problem solved, thanks a lot. Charles7c/charles7c.github.io@75090ce

xu4wang commented 1 year ago
// docs/vite.config.ts or docs/vite.config.js
import { defineConfig } from "vite";

export default defineConfig({
  resolve: {
    alias: {
        "mermaid": "mermaid/dist/mermaid.esm.mjs",
    },
  },
});

Problem solved, thanks a lot. Charles7c/charles7c.github.io@75090ce

Are you able to display mindmap with mermaid 9.3.0?

I got

> Syntax error in graph
> mermaid version 9.3.0

with below

mindmap
  root((mindmap))
    Origins
      Long history
      ::icon(fa fa-book)
      Popularisation
        British popular psychology author Tony Buzan
    Research
      On effectivness<br/>and features
      On Automatic creation
        Uses
            Creative techniques
            Strategic planning
            Argument mapping
    Tools
      Pen and paper
      Mermaid
Charles7c commented 1 year ago

I didn't test mindmap, I just made sure my previous flowchart display didn't report errors. I think it's another problem. 😄