Ionic 3.0.1 electron : Uncaught ReferenceError: require is not defined

I try using electron with new blank ionic 3.0.1 with ionic-cli@beta5 , when i add in index.html :slight_smile:

    var electron = require('electron');

When cal ionic serve the console error is:

Uncaught ReferenceError: require is not defined
** at localhost/:32**

How I can solve this to usin require in index.html ?

I found the solution :slight_smile:
With ionic-cli 3.0.1 to create a desktop electron application it’s verys simple:
In index.html add :slight_smile:

<script const electron = require('electron') </script

In a other page of your app .ts add:

delcare var electron: any

In your package.json add:

“main” : “main.js”

Where main.js sample :

  const electron = require('electron')
// Module to control application life.
const app =
// Module to create native browser window.
const {BrowserWindow, ipcMain} = electron;
const path = require('path')
const url = require('url')

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow

function createWindow () {
  // Create the browser window.
  mainWindow = new BrowserWindow({width: 800, height: 600})

  // and load the index.html of the app.
    pathname: path.join(__dirname, 'www/index.html'),
    protocol: 'file:',
    slashes: true

  // Open the DevTools.

      console.log("Received message: "+arg);

      console.log("Sending message back!");
      // Send message back!

  // Emitted when the window is closed.
  mainWindow.on('closed', function () {
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    mainWindow = null