LinuxCommandLibrary

electron-packager

Package Electron apps for distribution

TLDR

Package an application for the current architecture and platform

$ electron-packager "[path/to/app]" "[app_name]"
copy

Package an application for all architectures and platforms
$ electron-packager "[path/to/app]" "[app_name]" --all
copy

Package an application for 64-bit Linux
$ electron-packager "[path/to/app]" "[app_name]" --platform="[linux]" --arch="[x64]"
copy

Package an application for ARM macOS
$ electron-packager "[path/to/app]" "[app_name]" --platform="[darwin]" --arch="[arm64]"
copy

SYNOPSIS

npx electron-packager <sourcedir> [platform:arch] <appname> [options]

PARAMETERS

--all
    Package for all valid platforms/architectures

--arch
    Target architectures, e.g., x64, ia32, armv7l

--asar
    Package app into ASAR archive

--asar-unpack
    Comma-separated patterns to exclude from ASAR

--build-version
    Build version for macOS bundle

--deref-symlinks
    Dereference symlinks when copying

--dev
    Include devDependencies in prune

--download
    Always download Electron version

--electron-version
    Exact Electron version to use

--extend-session
    Extend download session lifetime

--extra-resource
    Add extra files to app bundle

--helper-bundle-ids
    macOS helper bundle IDs

--icon
    Icon file (.icns, .ico, .png)

--name
    App display name (overrides package.json)

--out
    Output directory

--overwrite
    Overwrite output directory

--platform
    Target platforms: linux, darwin, win32

--prune
    Prune unnecessary files with npm

--quiet
    Suppress all output

--tmpdir
    Temp directory for unpack

--version-string
    Set metadata like CompanyName, etc.

--win32metadata
    Windows-specific metadata

DESCRIPTION

Electron Packager is a command-line tool for bundling Electron applications into platform-specific distributables, including Linux binaries like AppImage or directories. It simplifies creating standalone executables from source code directories containing an Electron app's main script and assets.

Invoke it via npm as npx electron-packager or globally installed. Specify the source directory (containing package.json and app files), app name, target platforms (e.g., linux), architectures (x64, ia32, armv7l), and options for icons, ASAR packaging, pruning dependencies, and more. It downloads the matching Electron binary if needed, resolves dependencies with npm, and outputs ready-to-run folders or archives.

Ideal for developers needing quick packaging without CI complexity. Supports custom icons, version metadata, and protocol handlers. On Linux, produces directories with executables, usable via ./YourApp-linux-x64/YourApp or further packaged into DEB/RPM. Handles symlinks, extra resources, and quiet modes for scripting.

While versatile, it's best for prototypes; production favors tools like electron-builder for auto-updates and installers. Requires Node.js and npm.

CAVEATS

Deprecated in favor of electron-builder or electron-forge for advanced features like auto-updates; Linux output is directory-based, requires manual AppImage/DEB packaging; large downloads if Electron not cached.

INSTALLATION

npm install --save-dev electron-packager or npm i -g electron-packager; use npx for one-off.

LINUX OUTPUT

Creates AppName-linux-x64/ with executable; chmod +x needed; supports armhf via --arch=armv7l.

HISTORY

Originated 2015 by Max Ogden as electron-packager; evolved under electron-userland org; migrated to @electron/packager v17+ with Electron 20+ support; usage peaked pre-2018, now legacy.

SEE ALSO

npm(1), electron-builder(1)

Copied to clipboard