title: Electron JavaScript Uncaught TypeError: Cannot read property 'on' of undefined
body: <p>Hey I'm new to developing in Electron and I have no idea why I keep getting an error.</p>
  
  <p>the app is declared in the first couple of lines</p>
  
  <pre><code>const electron = require('electron')
  const app = electron.app
  const BrowserWindow = electron.BrowserWindow
  
  app.on('ready', createWindow)
  
  app.on('window-all-closed', function () {
  
  if (process.platform !== 'darwin') {
    app.quit()
  }
  })
  
  app.on('activate', function () {
  
  if (mainWindow === null) {
      createWindow()
    }
    })
  </code></pre>
  
  <p>Thanks in Advance.</p>