How to set up hot reinstallation on Electron

When working on the Electron application, it is very convenient to set up hot reinstallation so that the application can be updated without restarting.

You can do this using npm modulesElectronic reloading machine.

Suppose you have the following electronic sample application:


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

function createWindow() { // Create the browser window. const win = new BrowserWindow({ width: 800, height: 600, webPreferences: { nodeIntegration: true, }, })

// and load the index.html of the app. win.loadFile(‘index.html’) }



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

installationelectron-reloaderAs a development dependency:

npm install -D electron-reloader

Then add this line to the index.js file:

try {
} catch (_) {}

and that’s it! Now when you start the application using electron ., or npm start if you have

"start": "electron .",

in your package.json, any change you apply to the application files will be reflected in the application window.

More devtools tutorials: