I am creating a electron app and came across this problem:
I have a nice landing page. Now I want to switch between the html pages. As usual, index.js is in root directory and the html and javascript files in src/ directory.
I found a solution where the user had answered to set the "enableRemoteModule" to true. So eventually I did but still, when i did:
const electron = require('electron')
console.log(electron.remote) // Gave undefined
Is this the problem new or there is some problem with my own project code?
Browser code:
require('@electron/remote/main').initialize()
const { BrowserWindow } = require('@electron/remote')
let mainWindow
mainWindow = new BrowserWindow({
width: 700,
height: 600,
hasShadow: true,
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true,
},
});
mainWindow.on('closed', _ => {
console.log('closed')
mainWindow = null
})
mainWindow.loadFile("src/html/welcome.html")
New code after reading the comment. However, a new error:
Error: "@electron/remote" cannot be required in the browser process. Instead require("@electron/remote/main").