Package and ship

Package and make distributables

Use Electron Forge to create an unpacked application first, then build the platform-specific installer or archive.

Forge splits the last step in two, and the split is useful because each half fails in different ways.

Packaging builds the application directory: your bundled code plus the Electron binary, in the folder structure the operating system expects. Making wraps that directory in something you can distribute, like a DMG or an installer.

Package first

Stop npm start before you do anything. The packaged app must not depend on a running Webpack development server. If it works only because the dev server is up, you’ll find out the hard way on a user’s machine.

Then run:

npm run package

It produces something like out/Desktop Notes-darwin-arm64/Desktop Notes.app on an Apple Silicon Mac, or out/Desktop Notes-win32-x64/Desktop Notes.exe on Windows. Launch that directly.

This is where you catch paths that only worked in development. Repeat the core manual checks: the app loads, you can edit and save a note, you quit and restart and the note is still there, export works, the menu shortcuts work, navigation is denied, permissions are denied.

Also check the userData location. The packaged app has its own identity and can end up with a different folder than the development version. That’s expected, but confirm it’s the folder you intended.

Then make

npm run make

A maker converts the packaged app into a platform format. The Forge template ships with makers for Squirrel (a Windows installer), ZIP (macOS), and DEB and RPM (Linux). You can add a DMG maker for macOS.

Makers are platform-specific. Build macOS artifacts on macOS, Windows artifacts on Windows, and Linux artifacts on Linux. Cross-building works in a few cases, but only when the maker’s docs say so. Don’t assume.

When make fails

Find the stage first. make runs the whole pipeline, so the error can come from:

  • renderer bundling (a Webpack error)
  • a native module rebuild (a compiler error mentioning node-gyp)
  • signing (a certificate or keychain error)
  • the maker itself (a missing system tool like rpmbuild)

Each needs a different fix. Read the first error in the output, not the last.

Test like a user

Launching the folder under out/ proves packaging. Installing the distributable proves the maker. Do the second on a clean test account: install, launch, use the app, then uninstall. That’s the closest you get to what your users experience.

Lesson completed