Answer the question
In order to leave comments, you need to log in
How to fix "require is not defined" in Electron?
When trying to request in renderer.js:
writes that "require is not defined"
In the parameters of the window, webPrefereces is nodeIntegration: true, contextIsolation: false
const { ipcRenderer } = require('electron')
Answer the question
In order to leave comments, you need to log in
Create (modify) preload.js.
There you need to add
const {contextBridge, ipcRenderer} = require("electron");
contextBridge.exposeInMainWorld('ipcRenderer', ipcRenderer)
mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(app.getAppPath(), 'preload.js')
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question