Electron app exits without any error


#1

Hi all, I’ve been trying Electron for some days now. I started using it and starts fine but all of a sudden it automatically quit for no reason or error. Am I doing something wrong here? Here’s my main script

var app = require('app');
var BrowserWindow = require('browser-window');

app.on('ready',function(){
  var mainWindow = new BrowserWindow({
    width: 1200,
    height: 800
  });

mainWindow.loadUrl('file://' + __dirname + '/app/index.html');
mainWindow.maximize();
});

Thanks!


#2

You’ll want to keep a reference to mainWindow outside of the ready callback:

var mainWindow;

app.on('ready', function() {
  mainWindow = new BrowserWindow(...);
});

#3

@olmokramer Thanks, this was my issue too, blindly copying code from a blog post.