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

Version 9.4.0 - SyntaxError: Named export 'o' not found. The requested module './mermaid.95cd9c8e.js' is a CommonJS module, ... #4100

Closed
olayway opened this issue Feb 16, 2023 · 7 comments · Fixed by #4108
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@olayway
Copy link

olayway commented Feb 16, 2023

Description

When switching from mermaid version 9.3.0 to 9.4.0 in my Next.js app, the error below shows up:

ConfigReadError {
  error: file:///Users/o/Projects/flowershow-reproduction-repo/node_modules/mermaid/dist/mermaid.core.mjs:2
  import { o } from "./mermaid.95cd9c8e.js";
           ^
  SyntaxError: Named export 'o' not found. The requested module './mermaid.95cd9c8e.js' is a CommonJS module, which may not support all module.exports as named exports.
  CommonJS modules can always be imported via the default export, for example using:
  
  import pkg from './mermaid.95cd9c8e.js';
  const { o } = pkg;
  
      at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
      at ModuleJob.run (node:internal/modules/esm/module_job:189:5)
      at async Promise.all (index 0)
      at ESMLoader.import (node:internal/modules/esm/loader:530:24),
  configPath: '/Users/o/Projects/flowershow-reproduction-repo/contentlayer.config.ts',

...

The app uses Contentlayer to convert MD into JSON files.

mermaid is a dependency of the @flowershow/core package used in the app. The version specified there is ^9.3.0, so both 9.3.0 and 9.4.0 can be installed.

Steps to reproduce

  1. Clone this repo: https://github.com/olayway/flowershow-reproduction-repo
  2. Run npm i && npm run dev -> now everything works
  3. Go to package.json file and change the mermaid version in overrides to 9.4.0, like so:
  "overrides": {
      "mermaid": "9.4.0"
  }
  1. Run npm run dev again -> 💥

Screenshots

No response

Code Sample

No response

Setup

Desktop

  • OS and Version: [MacOS, ubuntu]

Additional Context

No response

@sidharthv96
Copy link
Member

@olayway Can you please try [email protected] ?

@veenified
Copy link

@sidharthv96 Same issue for 9.4.2-rc.1. See below...
4100_test942rc1

@sidharthv96
Copy link
Member

sidharthv96 commented Feb 19, 2023

10.0.0-rc.3 is explicitly marked as ESM. Can you try that?

Changes needed for v10: mermaid-js/mermaid-live-editor@bbd6378

@veenified
Copy link

That worked. Thank you @sidharthv96 !

@sidharthv96 sidharthv96 linked a pull request Feb 19, 2023 that will close this issue
10 tasks
@sidharthv96
Copy link
Member

@olayway @veenified can you please test if [email protected] works for you?
We're trying to add UMD back, so need to check if this breaks your package or not.

@rufuspollock
Copy link

rufuspollock commented Mar 30, 2023

I can confirm that this fix worked on a Flowershow site i.e. [email protected] works. /cc @olayway (re https://lifeitself.org build where this error showed up)

To add (2h later): that said, i then had this issue which i could resolve by removing mermaid (mdxMermaid plugin) temporarily from the contentlayerconfig.js:

ConfigReadError (.../contentlayer.config.js): SyntaxError: Named export 'visit' not found. The requested module 'unist-util-visit' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'unist-util-visit';
const { visit } = pkg;

Downgrading to v9.3.0 worked.

rufuspollock added a commit to life-itself/community that referenced this issue Mar 30, 2023
rufuspollock added a commit to life-itself/community that referenced this issue Mar 30, 2023
@yuis-ice
Copy link

I had the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants