Closed
Description
Describe the bug
项目中使用了 highlightjs 作为代码预览高亮工具。开发时并未发现异常,但是在构建时提示错误
build error:
file:///C:/demo-code/vitepress-error/docs/.vitepress/.temp/app.js:7
import hljsVuePlugin from "@highlightjs/vue-plugin";
^^^^^^^^^^^^^
SyntaxError: The requested module '@highlightjs/vue-plugin' does not provide an export named 'default'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:128:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:194:5)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
at async build (file:///C:/demo-code/vitepress-error/node_modules/.pnpm/vitepress@1.0.0-alpha.45/node_modules/vitepress/dist/node/serve-ebe7f464.js:42286:24)
ELIFECYCLE Command failed with exit code 1.
一开始我怀疑是该库存在问题,但是在常规 vue 应用中使用并构建都是没问题的。
Reproduction
最小复现
https://github.com/SaberA1ter/vitepress-error-demo
组件在 docs/.vitepress/theme/index.js
中注册,报错也是发生于此
Expected behavior
开发正常,但是构建报错。
System Info
win11
nodejs: v16.15.1
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.