title: NodeJS Electron with express
body: <p>I'm trying to make a webapplication using electron (for the website and desktop application) and express (for sessions etc.)</p>
  <p>Now, I got this as my app.js:</p>
  <pre><code>const express = require('express');
  const {app, BrowserWindow} = require('electron');
  
  exp = express();
  exp.set('views', __dirname + '/views/');
  exp.use(express.static(process.cwd() + '/views'));
  exp.get('/', function(req, res) {
      res.render('index', {});
  });
  
  function onAppReady() 
  {
      mainWindow = new BrowserWindow({
          width: 1080,
          height: 720,
          autoHideMenuBar: true,
          useContentSize: true,
          resizable: false
      });
  
      mainWindow.loadURL('http://localhost:5000/');
      mainWindow.focus();
      mainWindow.webContents.openDevTools();
  }
  
  app.on('ready', onAppReady);
  </code></pre>
  <p>Now, there's a few problems:</p>
  <ol>
  <li>If I use <code>node app.js</code>, I get this error:</li>
  </ol>
  <pre><code>Line: `app.on('ready', onAppReady);`
  
  TypeError: Cannot read property 'on' of undefined
  at Object.&lt;anonymous&gt; (/home/josh/chat_program/client/app.js:26:4)
  at Module._compile (module.js:571:32)
  at Object.Module._extensions..js (module.js:580:10)
  at Module.load (module.js:488:32)
  at tryModuleLoad (module.js:447:12)
  at Function.Module._load (module.js:439:3)
  at Module.runMain (module.js:605:10)
  at run (bootstrap_node.js:420:7)
  at startup (bootstrap_node.js:139:9)
  at bootstrap_node.js:535:3
  </code></pre>
  <ol start="2">
  <li>If I use <code>electron .</code>, the application starts, but I don't get either a request or a webpage. All I get is basic HTML without anything (only doctype HTML HEAD and BODY).</li>
  </ol>
  <p>I searched for a long time but couldn't find anything.</p>