Lesson 14 of 28 · javascript
Packaging & Distribution – electron‑builder
Duration: 12 mins
Packaging & Distribution – electron‑builder
electron‑builder is the most popular tool for creating installers for Windows (nsis), macOS (dmg, pkg) and Linux (AppImage, deb).
Install
npm install --save-dev electron-builder
Add build config to package.json
"build": {
"appId": "com.example.myapp",
"productName": "MyApp",
"directories": { "output": "dist" },
"files": [ "dist/**/*", "main/**/*", "preload/**/*", "package.json" ],
"mac": { "target": "dmg" },
"win": { "target": "nsis" },
"linux": { "target": "AppImage" }
}
Scripts
"scripts": {
"build": "electron-builder",
"dist": "npm run build"
}
Run npm run build – you’ll get platform‑specific installers in the dist/ folder.
Code signing (macOS)
- Create an Apple Developer ID certificate.
- Add to
buildconfig:
"mac": {
"identity": "Developer ID Application: Your Name (TEAMID)"
}
Code signing (Windows)
- Obtain a code‑signing certificate (pfx file)
- Add to config:
"win": {
"certificateFile": "cert.pfx",
"certificatePassword": "your‑password"
}