electron: Unable to use 'remote' module

Hi,

I’m trying to use the remote module but I’m getting an error when running my app:

App threw an error when running [TypeError: Cannot read property 'BrowserWindow' of undefined]

Here’s a simplified version of my code:

const remote = require('electron').remote;
const BrowserWindow = remote.BrowserWindow;
var win = new BrowserWindow({ width: 800, height: 600 });
win.loadURL('https://github.com');

Any idea what the problem can be?

Many thanks

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 18 (4 by maintainers)

Commits related to this issue

Most upvoted comments

@tinirlove The remote module is only available in the renderer process, you are attempting to access it in the browser/main process.

I guess they’ve changed the way to require remote. The blame information points to this change:

https://github.com/atom/electron/commit/eac2e7cc614d4e98e2828921f63d55f7b5e2c85c

Are you using v0.35.0 or above of Electron?