-
Notifications
You must be signed in to change notification settings - Fork 618
Open
Labels
help wantedExtra attention is neededExtra attention is needed
Description
使用electron-vite-vue时,刚开始正常,当我在main.ts引入puppeteer、Tesseract等插件后,报错:
Could not resolve "bufferutil" imported by "ws". Is it installed?
然后我在vite.config.ts中设置:
main: {
// Shortcut of `build.lib.entry`.
entry: 'electron/main.ts',
vite: {
build: {
rollupOptions: {
external: [
'bufferutil',
'utf-8-validate',
// 其他需要排除的模块
]
}
},
},
},
再次运行后就报错:
App threw an error during load
ReferenceError: __dirname is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/Users/mac/wwwroot/hc/my-electron-vite/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.

Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is needed