Electron app exits without any error


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');

  var mainWindow = new BrowserWindow({
    width: 1200,
    height: 800

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



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

var mainWindow;

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


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