Electron Desktop App Development · Lektion

Ihre Electron-App automatisch aktualisieren

Veröffentlichen Sie nahtlose Updates für Ihre Nutzer mit electron-updater, Update-Kanälen und einem ausgereiften Update-Ablauf.

Lektion 4 von 413 Schritte

Ihre Electron-App automatisch aktualisieren ist eine kostenlose Electron Desktop App Development-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Electron Desktop App Development-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Electron Desktop App Development-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Why Auto-Update Matters

Desktop apps are not auto-refreshed like web pages. Once a user installs your Electron app, you need a way to push new versions without asking them to re-download manually.

An auto-update system lets you ship bug fixes and features continuously, keeping every user on a recent, secure build.

  • Reduces support burden from stale versions
  • Delivers security patches fast
  • Improves retention with new features

The electron-updater Library

The most common solution is electron-updater, part of the electron-builder ecosystem. It handles checking, downloading, and installing updates across Windows, macOS, and Linux.

Install it as a runtime dependency, not a dev dependency, because it ships inside your app.

npm install electron-updater

Configuring the Publish Target

electron-updater reads a publish block in your build config to know where to fetch new versions. A common target is a generic HTTP server or a GitHub release.

"build": {
  "publish": [{
    "provider": "generic",
    "url": "https://updates.example.com/myapp"
  }]
}

Triggering an Update Check

In your main process, call autoUpdater.checkForUpdates() after the app is ready. This contacts your publish URL and compares versions.

Run this from the main process only, never the renderer.

const { autoUpdater } = require('electron-updater')

app.whenReady().then(() => {
  createWindow()
  autoUpdater.checkForUpdates()
})

Listening to Update Events

autoUpdater emits events you can hook into to drive your UI and logging.

  • update-available — a newer version exists
  • download-progress — bytes transferred
  • update-downloaded — ready to install
autoUpdater.on('update-available', () => {
  console.log('New version found')
})

autoUpdater.on('download-progress', (p) => {
  console.log('Progress: ' + Math.round(p.percent) + '%')
})

Installing the Downloaded Update

When update-downloaded fires, the new version is staged. Call quitAndInstall() to restart the app onto the new version.

It is good practice to prompt the user first instead of restarting unexpectedly.

autoUpdater.on('update-downloaded', () => {
  autoUpdater.quitAndInstall()
})

Update Channels

Channels let you ship pre-release builds to a subset of users. Common channels are latest, beta, and alpha.

Set the channel so testers receive early builds while everyone else stays on stable.

autoUpdater.channel = 'beta'
autoUpdater.allowPrerelease = true

Communicating Progress to the UI

Because autoUpdater lives in the main process, forward its events to the renderer through your preload bridge so the UI can show a progress bar.

autoUpdater.on('download-progress', (p) => {
  mainWindow.webContents.send('update-progress', p.percent)
})

Handling Errors Gracefully

Network failures and signature mismatches happen. Always listen for the error event so a failed update never crashes the app or blocks the user.

autoUpdater.on('error', (err) => {
  console.error('Update failed:', err == null ? 'unknown' : err.message)
})

Code Signing Requirements

On macOS and Windows, auto-updates only work if your app is code signed. Unsigned builds will fail the signature check on install.

  • macOS: Apple Developer ID certificate
  • Windows: Authenticode certificate

Signing also protects users from tampered update payloads.

Manual vs Silent Updates

You can disable automatic downloading and let users decide when to update by setting autoDownload = false, then calling downloadUpdate() on demand.

Choose silent background updates for consumer apps, manual control for enterprise tools.

autoUpdater.autoDownload = false

autoUpdater.on('update-available', () => {
  // ask user, then:
  autoUpdater.downloadUpdate()
})

Quick Check

Test your understanding of Electron auto-updates.

Recap

You learned how to ship seamless updates with electron-updater:

  • Configure a publish target
  • Call checkForUpdates() from the main process
  • React to update-available, download-progress, and update-downloaded
  • Use quitAndInstall() to apply
  • Code sign your builds and choose channels

A reliable update pipeline keeps your whole user base current and secure.

Kostenlos starten

Lerne JavaScript mit einem KI-Tutor — kostenlos

Schreibe und führe echten Code in deinem Browser aus, bekomme sofortige Hilfe von einem 24/7 KI-Tutor und setze dein Lernen im Web oder in der App fort.

Kurse
12
Lektionen
47

Häufig gestellte Fragen

Ist die Lektion „Ihre Electron-App automatisch aktualisieren“ kostenlos?

Ja — der vollständige Text von „Ihre Electron-App automatisch aktualisieren“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Electron Desktop App Development-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Electron Desktop App Development-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Ihre Electron-App automatisch aktualisieren“?

Veröffentlichen Sie nahtlose Updates für Ihre Nutzer mit electron-updater, Update-Kanälen und einem ausgereiften Update-Ablauf. Du übst Electron Desktop App Development mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Electron Desktop App Development zu starten?

Keine Vorkenntnisse erforderlich. Electron Desktop App Development auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „Ihre Electron-App automatisch aktualisieren“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Electron Desktop App Development-Lektion Code schreiben und ausführen?

Ja. Jede Electron Desktop App Development-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Architekturen mit mehreren Fenstern
  2. Hintergrundprozesse und Worker
  3. Integration mit Cloud-Diensten
  4. Ihre Electron-App automatisch aktualisieren
← Zurück zu Electron Desktop App Development