Update 2020, since this answer still appears at the top. For the original answer to work in current versions of Electron, you need to set enableRemoteModule
when creating the window in your main process.
const myWindow = new BrowserWindow({
webPreferences: {
enableRemoteModule: true
}
});
Original answer:
remote
is needed only to require other modules from inside a render process. In the main process you just get your modules directly from require('electron')
. Which it looks like is done in the example just with remote
unnecessarily added.
Render process:
const { remote } = require('electron');
const { BrowserWindow } = remote;
Main process:
const { BrowserWindow } = require('electron');