Asked 7 years ago
4 Apr 2017
Views 1537
jessica

jessica posted

how to install electron JS ?

i am trying to create cross platform desktop app with electron JS ,
dont know where to start with electron JS . How to install electron JS ?
Mitul Dabhi

Mitul Dabhi
answered Nov 30 '-1 00:00

on given folder , create package.json file with given code below

{
  "name": "myapp",
  "version": "0.1.0",
  "main": "index.js",
  "scripts": {
    "start": "electron ."
  },
  "author": "Mitul Dabhi <dabhi.mitul.developer@gmail.com> (http://gmail.com)",
  "license": "MIT",
  "devDependencies": {
    "electron-packager": "^8.6.0",
    "electron-prebuilt": "^0.25.3"
  },
  "description": ""
}


now open command prompt ,
on current folder run following command

npm i electron-prebuilt --save-dev


it will install "electron-prebuilt": "^0.25.3" as per package.json

now create index.js because as per package.json , "main": "index.js" , index.js is the landing file to load .
index.js

 var app = require('app');
var browserWindow = require('browser-window');
app.on('ready',function(){
 var mainWindow = new browserWindow({
 width : 800 , height : 600
 });
});



now run command on command prompt as belowed

npm start

it prompt a window
ravi

ravi
answered Nov 30 '-1 00:00



npm install electron -g


install electron globally not needed to install it per project
Post Answer