How to start to make your first Electron js app

Let’s go to the point. First of all you must download and install NodeJS. After it’s installed, you’re ready to start to make new project.

Open your Command Prompt, in Windows for example. Go to any folder/directory. Make new folder for your project, and go inside it. Then run this command:

npm init -y


npm i –save-dev electron

Edit your auto generated package.json file to be look like this:

  "name": "tinyhtmlwriter",
  "version": "1.0.0",
  "description": "",
  "main": "main.js",
  "scripts": {
    "start": "electron ."
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "electron": "^12.0.9"

Then make an index.html file, simply like this:

<!DOCTYPE html>
		<meta charset="UTF-8">
		<title>New Project</title>
		<p>Hello world!</p>

Then make main.js file like this one:

const { ipcMain, app, BrowserWindow } = require('electron')

function createWindow () {
	const win = new BrowserWindow({
		width: 1280,
		height: 720,
		webPreferences: {
			nodeIntegration: true,
			enableRemoteModule: true,



app.on('window-all-closed', () => {

app.on('activate', () => {
	if (BrowserWindow.getAllWindows().length === 0) {

ipcMain.on('quitprogram', (evt, arg) => {

That’s all. You’ve generated your new project files. To start the program, type this command in your Command Prompt:

npm start

To build your program as Windows executable, check out this post:

To build it for Mac, check out this post:


Leave a Reply

Your email address will not be published. Required fields are marked *