If you’ve built a powerful cross-platform desktop app using Electron.js, the next step is to package it for production so users can install and run it on Windows, macOS, and Linux.
In this guide, you’ll learn how to use Electron Builder to export your app with a configuration that supports:
- 💻 Windows
.exe
installer via NSIS - 🍎 macOS
.dmg
image - 🐧 Linux
.AppImage
and.deb
packages
We’ll also use build commands like build:win
, build:mac
, and build:linux
to generate exports per platform.
Project Prerequisites
Before starting, ensure you have:
- A working Electron app with
main.js
andindex.html
- Node.js and npm or yarn installed
- Icons for your app (
.ico
,.icns
, and.png
) - Electron and Electron Builder installed
Example Project Structure
/electron-app
├── main.js
├── index.html
├── assets/
│ └── icon.ico / icon.icns / icon.png
└── package.json
Step 1: Install Electron and Electron Builder
Install as dev dependencies:
npm install --save-dev electron electron-builder
Step 2: Configure package.json
Add the build
block
"build": {
"appId": "com.example.electronapp",
"productName": "Electron Test APP",
"icon": "assets/icon",
"win": {
"target": "nsis"
},
"linux": {
"target": ["AppImage", "deb"]
},
"mac": {
"target": "dmg"
},
"nsis": {
"oneClick": false,
"perMachine": true,
"allowToChangeInstallationDirectory": true
}
}
Add helpful scripts
"scripts": {
"start": "electron .",
"dev": "nodemon --watch * --exec electron .",
"build": "electron-builder",
"build:mac": "electron-builder --mac",
"build:win": "electron-builder --win",
"build:linux": "electron-builder --linux"
}
Step 3: Run Export Commands
Start the App Locally
npm start
or for live reloading during development:
npm run dev
Build for All Platforms (current OS only)
npm run build
Build for Windows (.exe)
npm run build:win
Generates an .exe
installer with NSIS wizard flow
Located inside /dist/Electron Test APP Setup 1.0.0.exe
Build for macOS (.dmg)
npm run build:mac
Only works on macOS (or CI with macOS runners)
Output: /dist/Electron Test APP-1.0.0.dmg
Build for Linux (.AppImage + .deb)
npm run build:linux
Works on Linux or WSL
Output includes:
/dist
├── electron-test-app-1.0.0.AppImage
└── electron-test-app_1.0.0_amd64.deb
Electron App index Page Preview:

Window dist folder Preview for .exe file

Troubleshooting Tips
Issue | Fix |
---|---|
.dmg won’t build on Windows | Must use macOS or CI with macOS |
Icons missing | Ensure icons are in assets/ and format is correct |
App won’t open on Mac | Sign and notarize via Apple Developer |
Linux AppImage won’t launch | Use chmod +x your-app.AppImage |
Final Thoughts
Electron Builder makes it easy to build cross-platform installers with a few commands. With your setup:
- You’ve added per-platform build scripts
- You’re generating installers for Windows, macOS, and Linux
- Your Electron app is now ready to ship to the world