vite-electron-react-starter
vite-electron-react-starter copied to clipboard
Uncaught ReferenceError: __dirname is not defined when I try to import electron
I get this when I try to add import such as import { ipcRenderer } from 'electron';
:
Uncaught ReferenceError: __dirname is not defined
at node_modules/electron/index.js (index.js:4)
at __require (chunk-KYLA5N2V.js?v=0feadafd:12)
at dep:electron:1
Although electron is in externals for sure
I also tried adding this:
optimizeDeps: {
exclude: ['electron'],
},
to my renderer.vite.config.
That resulted in error Uncaught SyntaxError: The requested module '/@fs/home/capaj/work-repos/subz-desktop/node_modules/electron/index.js?v=2d23cc12' does not provide an export named 'default'
Any idea how to resolve this issue?
Electron is in externals by default, Did you upgrade any dependency ?
I also have this problem when I try to add import { ipcRenderer } from 'electron' . can you solve this problem? thanks @soulsam480
Will check.
Hii @LiXiaoLongsgithub @capaj , the repo has been updated to latest upstream. Can you try the new template now ? If it's possible
As far as I know you should import backend stuff in the preload package, there you can re-export and import from render to use.