#"fs" and "path" error when attempting to import IpcRenderer

12 messages · Page 1 of 1 (latest)

cedar spruce
#

Hey Electron Community,

I am trying to make an app with react & electron. I am finally to the point I need to send some data from my front end (react) to the back end (electron) to make some files and start making them communicate in general. But anytime I try to import IpcRenderer on my React front end I get the same error..

I have tried to import it both as import and require it, either way.

ERROR in ./node_modules/electron/index.js 1:11-24
Module not found: Error: Can't resolve 'fs' in 'S:\Projects\auto-budgeter\node_modules\electron'

That line in index.js is <React.StrictMode> that it mentions in the error. Is it just a werid thing with React's Strict mode? What am I missing here, im not sure what else I can give you to help other than that.

rugged bronze
#

Use a preload file

kindred prawn
# rugged bronze Use a preload file

You need to describe more detail.
He does want to send the file from ipcRenderer to main process.
In this case, you have to change the file to binary array(Unit8Array) and send it to main process via ipcRenderer.send.

#

But if the file size is large then the webContent can be crashed.

rugged bronze
#

What are you talking about?

kindred prawn
#

So, to solve this problem, we have to use cookie or key(such as key).

rugged bronze
#

He only talked about using ipcRenderer

kindred prawn
#

yes

#

i am saying about that.

rugged bronze
#

No, you're talking about sending a file which is not what he asked

cedar spruce
#

Yeah the original question was having to do with React talking to the electron back-end. I have a little front end made and I want to send some data to the backend so I can mess with it. Everytime I try to import IpcRenderer into React I get the error above.