vite-plugin-electron
vite-plugin-electron copied to clipboard
VM4 sandbox_bundle:2 Error: module not found: node:module
我在preload/index.ts文件中引入了 iconv-lite或者 secure-electron-license-keys类库 发现都报错
VM4 sandbox_bundle:2 Unable to load preload script: F:\electron\dist-electron\preload\index.mjs
VM4 sandbox_bundle:2 Error: module not found: node:module
at preloadRequire (VM4 sandbox_bundle:2:82852)
at <anonymous>:3:21
at runPreloadScript (VM4 sandbox_bundle:2:83516)
at VM4 sandbox_bundle:2:83813
at VM4 sandbox_bundle:2:83968
at ___electron_webpack_init__ (VM4 sandbox_bundle:2:83972)
at VM4 sandbox_bundle:2:84095
我尝试使用了require或者import导入包都是不行这是我哪块配置不对还是兼容性问题导致的呢
需要在主进程中开启 webPreferences: { nodeIntegration: true }。
你多看下 Electron 官方文档,或者在主进程中使用一些 Node.js 的库试试。