Post

Convert n8n into a Desktop App Using Electron

Convert n8n into a Desktop App Using Electron

Convert n8n into a Desktop App Using Electron

Step 1: Install Electron

First, install Electron globally:

1
npm install -g electron

Step 2: Create an Electron Project

Create a new folder and navigate into it:

1
mkdir n8n-desktop && cd n8n-desktop

Initialize a new Node.js project:

1
npm init -y

Install Electron as a dependency:

1
npm install electron

Step 3: Create main.js (Electron Main Process)

Inside n8n-desktop, create a file named main.js and add the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const { app, BrowserWindow } = require('electron');
const { exec } = require('child_process');

let mainWindow;

app.on('ready', () => {
    // Start n8n process
    const n8nProcess = exec('n8n', (error, stdout, stderr) => {
        if (error) {
            console.error(`Error starting n8n: ${error}`);
        }
        console.log(stdout);
    });

    // Create a new window
    mainWindow = new BrowserWindow({
        width: 1200,
        height: 800,
        webPreferences: {
            nodeIntegration: false
        }
    });

    // Load n8n UI
    mainWindow.loadURL('http://localhost:5678');

    mainWindow.on('closed', () => {
        mainWindow = null;
        n8nProcess.kill(); // Stop n8n when the app is closed
    });
});

Step 4: Modify package.json

Open package.json and add the following:

1
2
3
4
"main": "main.js",
"scripts": {
  "start": "electron ."
}

Step 5: Run Your Desktop App

Now, start the Electron app:

1
npm start

Step 6: Package as a Desktop App

You can package it into an executable using Electron Packager :

1
2
npm install -g electron-packager
electron-packager . n8n-desktop --platform=win32 --arch=x64 --out=dist

For Mac :

1
electron-packager . n8n-desktop --platform=darwin --arch=x64 --out=dist

For Linux :

1
electron-packager . n8n-desktop --platform=linux --arch=x64 --out=dist

its generate executable file in dist/ folder , execue that

Reflected XSS

This post is licensed under CC BY 4.0 by the author.