electron-vite / electron-vite-vue

🥳 Really simple Electron + Vite + Vue boilerplate.

Home Page:https://electron-vite.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] electron降级到22版本提示不支持require() of ES Module

nikinikinico opened this issue · comments

Describe the bug

似乎是vite-plugin-electron插件的问题

vite-plugin-electron 好像是要在electron>=23.x.xx
将 vite-plugin-electron 降级到 0.15.6

ELectron 从 28 开始才支持 ESM。你降级到 22 肯定会出现这种问题。
就算你不用 Electron 用 Node.js 不支持 ESM 的版本一样会出现这个问题。
找你的装的 npm 看看哪个入口文件是 ESM 的,要么降级 npm 包版本,要么写全 require('module-name/xxx/xxx.js') 路径。

我用npm create electron-vite创建的项目,再将electron降级到22版本的就没有问题。如果直接拉这个仓库的源码降到22版本就有问题。我看两个版本vite-plugin-electron的使用方式有些不一样,是不是这个原因
image

create-electron-vite 是最小化模板,这个项目多了好多依赖。
看你个人需求

create-electron-vite 是最小化模板,这个项目多了好多依赖。 看你个人需求

好的,谢谢