Closed Zuckabub closed 2 years ago
Facing exact issue, any luck with solution?
Hi @MohitDeshwal, I did get past this in the end, but it required a change in my plan on how to manage state in my electron app, rather than getting what I was trying to do working (Which I now think never would have).
The current security recommendations for electron(https://www.electronjs.org/docs/latest/tutorial/security) point 3 (Enable context isolation in all renderers that display remote content) means you won't be able to utilize a state synching package like 'electron-redux' if you have contextIsolation set to true. You will not be able to utilize any Electron internals in your rendering process.
For my project, I just stopped trying to sync state between renderer and main (using electron-redux) - in the main process I don't have redux, I only use redux in my renderer process.
In places where I need data from main process in state I just expose a method in my preload script using contextBridge, when the render process gets it's response, I stuff it into state then.
https://docs.w3cub.com/electron/tutorial/context-isolation This site here has some starter info on setting up your contextBridge
I have an app created with electron-forge trying to utilize electron-redux v1.5.4. I'm also using @reduxjs/toolkit
I have implented my mainRenderer and storeRenderer in the manner described in the readme file, adjusted for @reduxjs/toolkit
mainStore.js
rendererStore.js
When I run compiling the Renderer Code I get the following error:
ModuleNotFoundError: Module not found: Error: Can't resolve 'fs' in 'C:\MyDev\AirFarmer\node_modules\electron'
, The chrome window gives a bit more detail:I've read this is related to webpack v5+
had a similar issue with "path" which I was able to solve with by updating the webpack.render.config:
I've tried lots of things already including setting
nodeIntegration: true
in webPreferences when creating the browser window.Has anybody else experienced this? Does anybody have a solution? Thanks
UPDATE - Still an issue The cause is that "forwardToMain.js" has
require("electron");
, which in turn requires 'fs'.