isElectronApp is true but ipcRenderer is null
See original GitHub issueHi,
i packed my angular app to an .exe with electron-packager. Inside my app I want to use sendSync from the ipcRenderer, but then I get an error because the ipcRenderer is null although isElectronApp is true…
This is my code where the window is created:
` const { app, BrowserWindow } = require(‘electron’); const path = require(‘path’); const url = require(‘url’);
let win;
const createWindow = () => { win = new BrowserWindow({ width: 800, height: 600, icon: path.join(__dirname, ‘assets/test.png’), }); win.setKiosk(true);
win.loadURL(url.format({ pathname: path.join(__dirname, ‘index.html’), protocol: ‘file:’, slashes: true }));
win.on(‘closed’, () => { win = null; }); }
app.on(‘ready’, createWindow);
app.on(‘window-all-closed’, () => { if (process.platform !== ‘darwin’) { app.quit(); } });
app.on(‘activate’, () => { if (win === null) { createWindow(); } }); `
What I am doing wrong?
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (2 by maintainers)
Try setting
nodeIntegration
totrue
.new BrowserWindow({ webPreferences: { nodeIntegration: true } });
Actually I just solved my issue! By using a conditional to check what page the preload script is running on, I was able to delete the node window properties but only on the child window. Keeping these properties on the parent window is required for icpRenderer to work in that context, but I do not need icpRenderer in the child window. Hope this helps!