vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
13.31k stars 2.15k forks source link

require() of ES Module vitepress/.temp/app.js not supported. vitepress dev可以正常运行,但是vitepress build 报错 vitepress: 0.22.4 #4145

Closed lianjunbin closed 3 months ago

lianjunbin commented 3 months ago

Describe the bug

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/lianjunbin/Documents/pix-component/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/lodash.js from /Users/lianjunbin/Documents/pix-component/docs/.vitepress/.temp/app.js not supported. Instead change the require of lodash.js in /Users/lianjunbin/Documents/pix-component/docs/.vitepress/.temp/app.js to a dynamic import() which is available in all CommonJS modules. at Module. (/Users/lianjunbin/Documents/pix-component/docs/.vitepress/.temp/app.js:9:16) at renderPage (/Users/lianjunbin/Documents/pix-component/nodemodules/.pnpm/vitepress@0.22.4@algolia+client-search@4.14.1_@types+react@18.3.3_react-dom@18.3.1_react@18.3.1_sass@1.53.0/node_modules/vitepress/dist/node/serve-3035f99b.js:41110:25) at Object.build (/Users/lianjunbin/Documents/pix-component/nodemodules/.pnpm/vitepress@0.22.4@algolia+client-search@4.14.1_@types+react@18.3.3_react-dom@18.3.1_react@18.3.1_sass@1.53.0/node_modules/vitepress/dist/node/serve-3035f99b.js:41259:15) { code: 'ERR_REQUIRE_ESM'

Reproduction

搞不懂 同样的代码用vitepress dev可以正常运行,但是vitepress build 报错。

Expected behavior

解决打包编译问题

System Info

node v18.20.4 
sass: ^1.53.0
vite: ^2.9.13
vitepress: 0.22.4

Additional context

No response

Validations

brc-dd commented 3 months ago

vitepress v0.x are no longer supported and many things might not work there. The latest version is v1.3.2.