Electron Application Packaging and Automatic Updates
🎯 Introduction
During development, npm start runs your project source. Users need an application they can install or open directly, so before release you must bundle Electron, page code, and resources into an application package.
This article answers three questions:
- What belongs in
package.jsonandforge.config.js? - What do
packageandmakeeach produce? - What roles do signing and automatic updates play in a release?
🧱 Two configuration files with separate responsibilities
Start with this table:
| File | Responsibility | Configuration in this article |
|---|---|---|
package.json | Basic project information and commands | App name, version, entry point, packaging scripts |
forge.config.js | Electron Forge packaging rules | App icon, installer formats, target platforms |
Put the application name and version in package.json, and the packaging icon and installer formats in forge.config.js. These are separate configuration entry points.
The icon option in BrowserWindow controls the runtime window icon, which differs from the packaged application icon. To avoid confusion, this article leaves it out of packaging; beginner projects can configure only Forge's application icon.
🧰 Install Electron Forge
This example uses Node.js 24.x LTS, Electron 44.0.0, and Electron Forge 7.11.2. Install Forge in your existing Electron project:
npm install --save-dev @electron-forge/cli@7.11.2
npx electron-forge import
7.11.2; follow your installed version and the official documentation in practice.After importing, the project usually has these three additional commands:
{
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make"
}
}
✍️ Configure package.json
Use package.json for the application's basic identity:
{
"name": "electron-course",
"productName": "Electron Course",
"version": "1.0.0",
"description": "An Electron learning project",
"author": "Your Name",
"main": "main.js",
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make"
}
}
The key distinction is: this article does not put icon in package.json. Configure the application icon in forge.config.js below.
⚙️ Configure forge.config.js
Create forge.config.js in the project root:
module.exports = {
packagerConfig: {
icon: './assets/icon',
},
makers: [
{
name: '@electron-forge/maker-zip',
platforms: ['darwin'],
},
{
name: '@electron-forge/maker-squirrel',
platforms: ['win32'],
},
{
name: '@electron-forge/maker-deb',
platforms: ['linux'],
},
],
};
Focus on two parts of this configuration:
1. packagerConfig.icon
packagerConfig: {
icon: './assets/icon',
}
This tells Forge to find the application icon in assets. Specify the path without an extension; Forge selects the corresponding icon format for the target system:
assets/
├── icon.ico # Windows
├── icon.icns # macOS
└── icon.png # Linux
This configures the packaged application's icon, rather than an image in a Vue page or an icon set dynamically at runtime.
2. makers
makers determines the distribution formats produced by npm run make:
| Maker | Target system | Purpose |
|---|---|---|
maker-zip | macOS | Create a zip archive |
maker-squirrel | Windows | Create a Windows installer |
maker-deb | Linux | Create a .deb package |
Remove makers for systems you do not need to publish to. When learning, generating one artifact for your current system makes inspection easier.
📦 The difference between package and make
First, run:
npm run package
package combines source code, pages, and the Electron runtime into a runnable application directory. Use it first to verify:
- Whether the app starts.
- Whether page resource paths are correct.
- Whether the icon and application name take effect.
After confirming that the application directory runs, execute:
npm run make
make uses the makers configuration to turn that directory into an installer or archive for installation or distribution.
Remember the distinction this way:
package: Assemble a runnable application
make: Turn that application into files ready to deliver
🔏 What to know about signing first
Signing tells the operating system who published an app and confirms that the package has not been modified since signing.
The next article covers the full signing workflow. For now, understand that production releases need platform certificates, and Forge uses them during packaging. Without certificates, you can skip signing while learning.
The scope differs by goal:
| Goal | What this section helps you do |
|---|---|
| Local learning | Package the app without signing |
| Local signature verification | Configure a certificate, sign with Forge, and check the result |
| Public distribution | Also requires obtaining certificates, notarization, installer testing, and secure credential storage |
macOS: Enable signing in Forge
Prepare these prerequisites:
- An Apple Developer Program account.
- A
Developer ID Applicationcertificate installed on the current Mac. - Xcode Command Line Tools.
First, check that your Mac can find a signing certificate:
security find-identity -p codesigning -v
Then add osxSign: {} to the existing packagerConfig:
module.exports = {
packagerConfig: {
icon: './assets/icon',
osxSign: {},
},
};
osxSign: {} tells Forge to sign the app using a certificate already installed on the current Mac. Then run:
npm run package
If signing succeeds, the generated macOS app has a code signature. Check it with:
codesign --verify --deep --strict --verbose=2 \
out/electron-course-darwin-arm64/Electron\ Course.app
Public macOS distribution usually also requires notarization. It needs an Apple account or App Store Connect API key. Store credentials in environment variables or the keychain, rather than committing them in forge.config.js.
Public macOS distribution therefore requires at least Developer ID Application signing, packaging, submission to Apple for notarization, and distribution after notarization succeeds. Running npm run package alone does not complete a user-facing macOS release.
Windows: Configure a certificate for the installer
Windows signing requires a code signing certificate file, such as .pfx, and its password. Configure the certificate in the Windows maker:
module.exports = {
makers: [
{
name: '@electron-forge/maker-squirrel',
config: {
certificateFile: process.env.WINDOWS_CERTIFICATE_FILE,
certificatePassword: process.env.WINDOWS_CERTIFICATE_PASSWORD,
},
},
],
};
Temporarily set the environment variables in Windows PowerShell, then generate the installer:
$env:WINDOWS_CERTIFICATE_FILE = 'C:\certs\electron-course.pfx'
$env:WINDOWS_CERTIFICATE_PASSWORD = 'your-certificate-password'
npm run make
For public Windows distribution, also confirm that signing covers the final distributed installer. Test installation, startup, and uninstallation on a clean Windows machine without a development environment. Certificate types, timestamp services, and SmartScreen prompts are also part of the Windows release workflow.
These steps cover the core operation of signing with certificates through Forge. They do not replace obtaining platform certificates, macOS notarization, or production release checks.
🔄 Implement automatic updates
We will use a beginner-friendly route: a public GitHub repository + GitHub Releases + update-electron-app.
The complete flow is:
Forge generates installers
↓
Publish to a GitHub Release
↓
The app checks releases on startup
↓
Download a new version and prompt for a restart
This approach has several prerequisites: the app runs on macOS or Windows, its code is in a public GitHub repository, and its build artifacts are published to GitHub Releases. macOS apps must also be signed. Linux does not use Electron's built-in automatic updater; updates are usually handled by the distribution's package manager.
Step 1: Install update dependencies
This article uses update-electron-app 3.3.0 and Forge GitHub Publisher 7.11.2:
npm install update-electron-app@3.3.0
npm install --save-dev @electron-forge/publisher-github@7.11.2
Step 2: Add the repository URL to package.json
The update tool needs to know which GitHub repository belongs to the app:
{
"repository": {
"type": "git",
"url": "https://github.com/your-username/electron-course.git"
}
}
Replace the example with your own public repository URL.
Step 3: Configure GitHub Publisher
Add publishers to forge.config.js:
module.exports = {
publishers: [
{
name: '@electron-forge/publisher-github',
config: {
repository: {
owner: 'your-username',
name: 'electron-course',
},
},
},
],
};
Step 4: Start automatic updates in the main process
Add this at the top of main.js:
const { updateElectronApp } = require('update-electron-app');
updateElectronApp();
This makes the app check for updates on startup, download new versions in the background, and prompt users to restart for installation. It does not produce meaningful update results through npm start in development; test the packaged app.
Step 5: Publish a new version
Change the version in package.json from 1.0.0 to 1.0.1, then configure a GitHub token:
export GITHUB_TOKEN='your-github-token'
npx electron-forge publish
In Windows PowerShell, use:
$env:GITHUB_TOKEN = 'your-github-token'
npx electron-forge publish
Forge generates distribution files for the current system and uploads them to a GitHub Release. The old app version can discover the new version the next time it starts.
🧾 Summary
package.jsonstores app information, the entry point, and commands.forge.config.jsstores Forge packaging rules and installer formats.packagerConfig.iconconfigures the packaged app icon; do not duplicate it inpackage.json.packagecreates a runnable application directory;makecreates distribution files.- macOS signing uses
packagerConfig.osxSign; Windows certificates and passwords are configured in the maker. - GitHub Releases and
update-electron-applet macOS and Windows apps check for and download new versions.
❓ Questions and answers
Q1: Why is icon missing from the package.json example?
This article configures the icon through Forge, using packagerConfig.icon in forge.config.js.
Q2: Should I run both package and make?
Run package first to check that the app starts, then make to generate distribution files.
Q3: Are signing and automatic updates required to learn Electron?
No. Start with package and make while learning. Prepare certificates and an update publishing environment for production distribution later.
Q4: Why can't automatic updates be tested only through npm start?
Automatic updates check published installers and version numbers. Development has no corresponding release artifacts, so test using packaged old and new versions.
🧪 Practice
Exercise 1: Change the application name in package.json to your own name.
Exercise 2: Keep only the maker for your current system in forge.config.js, then run:
npm run package
npm run make
Observe the artifacts each command creates in out.
Exercise 3: If you have a public GitHub repository, add repository, the publisher, and updateElectronApp() as described above, and create a test release.
🎉 You now understand the relationship between basic project information, Forge packaging rules, application directories, and distribution files.
