Quick Start Guide
This guide will help you set up electron-builder in your Electron project and create your first build.Prerequisites
Before you begin, make sure you have:- An Electron project initialized
- electron-builder installed as a dev dependency (Installation Guide)
Setup Steps
Configure package.json metadata
Specify the standard fields in your application
package.json. These fields are used for your app’s metadata:package.json
The
name, description, version, and author fields are required for proper app packaging.Add build configuration
Add the
build configuration to your package.json:package.json
Alternative Configuration Files
Instead ofpackage.json, you can create:Add application icons
Add icons for your application. electron-builder will automatically use the correct icon format for each platform.Create an Learn more about icon requirements.
build directory in your project root and add your icons:electron-builder can generate all icon formats from a single 1024x1024 PNG file. Place it at
build/icon.png and electron-builder will handle the conversions.Add build scripts
Add build scripts to your Script descriptions:
package.json:package.json
app:dir- Generates the package directory without packaging it (useful for testing)app:dist- Packages the app in a distributable format (DMG, installer, etc.)postinstall- Ensures native dependencies match the Electron version
Important Notes
Native Dependencies
If you have native addons that are part of your application (not as a dependency), setnodeGypRebuild to true in your build configuration:
package.json
Production Code Signing
For applications that will be shipped to production, you should sign your application. This is required for macOS and recommended for Windows.
Example: Complete package.json
Here’s a complete example of apackage.json configured for electron-builder:
package.json
Using Boilerplates
Community Boilerplates
Consider using these community-maintained boilerplates:- electron-react-boilerplate - A boilerplate for scalable cross-platform desktop apps
- electron-vue-vite - Electron + Vue3 + Vite5 boilerplate
- vite-electron-builder - Secure boilerplate based on Vite (supports multiple frameworks)
- electronjs-with-nextjs - ElectronJS with NextJS and TypeScript
Next Steps
Configuration
Explore all configuration options for advanced builds
Code Signing
Learn how to sign your application for distribution
Auto Update
Set up automatic updates for your application
Publishing
Publish your app to GitHub Releases, S3, and more
Debugging
If you encounter issues during the build process, enable debug logging:FPM_DEBUG- More details about building Linux targets (except snap and AppImage)DEBUG_DMG=true- More verbosity fromhdiutilon macOS