Joao Garin Joao Garin - 1 month ago 12x
Javascript Question

Angular2 and electron accessing browserWindwow object

I am using Angular2 with Electron and WebPack.

I am trying to get a hold to the


I am doing on the top of my component

import * as electron from 'electron';

However when doing :

this.authWindow = new electron.BrowserWindow({ width: 800, height: 600, show: false});

I get an error on runtime

ORIGINAL EXCEPTION: TypeError: electron.BrowserWindow is not a function

When logging electron itself looks like just a function so there is no
object in it.

function defineProgram(name, opts) {
var program = new Program(name, opts);
return program;

In WebPack I am using
to target Electron.

The intention is to open a new browser window object much like done here


To communicate between the renderer process and the main process, you need to use the Remote API (

Something like this should work:

const remote = require('electron').remote;
const BrowserWindow = remote.BrowserWindow;

this.authWindow = new BrowserWindow({ width: 800, height: 600, show: false});