Skip to content

Failed to build with vitepress #223

Open
@imengyu

Description

@imengyu

Describe the bug

I m using vue-codemirror in vitepress project, it work fine in development mode, but it can not build, i receive this error:

✖ rendering pages...
build error:
file:///F:/Programming/WebProjects/test/.vitepress/.temp/index.md.js?t=1714413605827:3
import { Codemirror } from "vue-codemirror";
         ^^^^^^^^^^
SyntaxError: Named export 'Codemirror' not found. The requested module 'vue-codemirror' 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 'vue-codemirror';
const { Codemirror } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:134:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:217:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:323:24)
    at async renderPage (file:///F:/Programming/WebProjects/test/node_modules/vitepress/dist/node/serve-CXVdC751.js:46638:28)
    at async pMap.concurrency (file:///F:/Programming/WebProjects/test/node_modules/vitepress/dist/node/serve-CXVdC751.js:46873:11)
    at async file:///F:/Programming/WebProjects/test/node_modules/vitepress/dist/node/serve-CXVdC751.js:2614:20

I have created a brand new vitepress project, but unfortunately, this issue still exists cannot build.

It seems that vue-codemirror has not been updated for a long time. Does it support the latest vite?

Reproduction

  1. Open this minimal replication project demo.zip
  2. Install dependencies
  3. Run vitepress build to execute the build,
  4. It displays an error message

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i9-11900KF @ 3.50GHz
    Memory: 48.07 GB / 63.88 GB
  Binaries:
    Node: 20.12.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.5.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (123.0.2420.97)
    Internet Explorer: 11.0.19041.3636
  npmPackages:
    @codemirror/lang-javascript: ^6.2.2 => 6.2.2
    codemirror: ^6.0.1 => 6.0.1
    vitepress: ^1.1.4 => 1.1.4
    vue-codemirror: ^6.1.1 => 6.1.1

Used Package Manager

npm

Validations

  • Read the the documentation in detail.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
  • The provided reproduction is a minimal reproducible example of the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions