Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run electron project

Today I have just started to learn Electron.

I don't understand more about it but I think:

  • Electron is a language like C#.
  • Atom is a Text Editor like notepad++.

Inside Atom.io I have created a Folder called Demo which has 3 files as follows:

Demo
  |--package.json
  |--main.js
  |--index.html

In package.json:

{
  "name"    : "Demo",
  "version" : "0.1.0",
  "main"    : "main.js"
}

In main.js:

const electron = require('electron');

const {app} = electron;

const {BrowserWindow} = electron;

let win;

function createWindow() {

  win = new BrowserWindow({width: 800, height: 600});

  win.loadURL(`file://${__dirname}/index.html`);

  win.webContents.openDevTools();

  win.on('closed', () => {
    win = null;
  });
}

app.on('ready', createWindow);

// Quit when all windows are closed.
app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit();
  }
});

app.on('activate', () => {
  if (win === null) {
    createWindow();
  }
});

In index.html:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Hello World!</title>
  </head>
  <body>
    <h1>Hello World!</h1>
  </body>
</html>

Now, I want to know that how can I run this project? Do I need to install anything else to run it?

I am using Windows 8.1

like image 914
Vishal Avatar asked Dec 10 '22 16:12

Vishal


1 Answers

Electron is not a language. It's a framework to build cross-platform desktop applications with web technologies (HTML, CSS, JS) built with NodeJS.

So when to build app with Electron, you have both ElectronAPI and npm ecosystem at your disposal.

To run your Electron app, you can follow:

  • Run your app - Quick Start guide

and/or clone electron-quick-start repo.

like image 91
Florent Ferry Avatar answered Dec 27 '22 21:12

Florent Ferry