title: electron.remote is undefined in render process
body: <p>I am trying to use dialog when a user clicks button, bug got an error <code>Uncaught TypeError: Cannot read property 'dialog' of undefined</code>. The result from the console log is <code>undefined</code></p>
  <p><code>main.js</code> file</p>
  <pre><code>const { app, BrowserWindow } = require('electron');
  const path = require('path');
  
  if (require('electron-squirrel-startup')) {
    app.quit();
  }
  
  const createWindow = () =&gt; {
    const mainWindow = new BrowserWindow({
      width: 800,
      height: 600,
      webPreferences: {
        nodeIntegration: true
      }
    });
    mainWindow.loadFile(path.join(__dirname, './src/index.html'));
  
    mainWindow.webContents.openDevTools();
  };
  
  app.on('ready', createWindow);
  
  app.on('window-all-closed', () =&gt; {
    if (process.platform !== 'darwin') {
      app.quit();
    }
  });
  
  app.on('activate', () =&gt; {
    if (BrowserWindow.getAllWindows().length === 0) {
      createWindow();
    }
  });
  </code></pre>
  <p><code>index.html</code> file</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;meta charset=&quot;UTF-8&quot;&gt;
      &lt;title&gt;welcome&lt;/title&gt;
      &lt;link rel=&quot;stylesheet&quot; href=&quot;index.css&quot;&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;p id=&quot;create&quot;&gt;Create New File&lt;/p&gt;
      &lt;p id=&quot;open&quot;&gt;Open File&lt;/p&gt;
      &lt;script src=&quot;./index.js&quot;&gt;&lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p><code>index.js</code> file</p>
  <pre><code>const { remote } = require('electron');
  console.log(remote); // undefined
  
  const open = document.querySelector('#open');
  const create = document.querySelector('#create');
  
  open.addEventListener('click', function () {
    remote.dialog.showErrorBox('error', '123'); 
  });
  </code></pre>