'IPC send - TypeError: Cannot read properties of undefined (reading 'send')

I am trying to send messages between JavaScript files. I have a main.js file and have multiple ipc renderer files.

When I use the code below in all of my renderer files

const { ipcRenderer} = require('electron')

I get the error below (just 1 file has no errors when sending message)

TypeError: Cannot read properties of undefined (reading 'send')

How can I solve this and send messages to main.js from multiple JS files ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source