CLI
How to use the command line interface (CLI) commands for Electron Forge
Overview
Forge's CLI is the main way to run Electron Forge commands. It consists of a thin wrapper for its core API. Configuration for these commands is done through your Forge configuration object.
If you want to use the core API programmatically, see the Programmatic usage section below.
Forge's CLI uses comma-separated value strings to pass multiple arguments into a single flag. Depending on your terminal, these comma-separated values may need to be enclosed in quotation marks.
Installation
To use the Forge CLI, install the @electron-forge/cli
module into your project as a devDependency. If you're using the create-electron-app
script, this module will already be installed for you.
Bootstrap commands
These commands help you get started with Forge. If you're just getting started with Electron Forge, we recommend you follow the Getting Started or Importing an Existing Project guides.
Init
We recommend using the create-electron-app
script (which uses this command) to get started rather than running Init directly.
This command will initialize a new Forge-powered application in the given directory (defaults to .
, the current directory).
Please note if you want to use a non-builtin template, it must be installed globally before running the init
command.
Options
All flags are optional.
--template
Template Name
Name of the template to use to make this new app
--copy-ci-files
N/A
Set if you want to copy templated CI files (coming soon)
Usage
Import
This command will attempt to take an existing Electron app and make it compatible with Forge. Normally, this just creates a base Electron Forge configuration and adds the required dependencies.
Options
There are no options for the Import command.
Usage
Build commands
The Package, Make, and Publish commands are the three main steps of the Electron Forge build pipeline. Each step relies on the output of the previous one, so they are cascading by default (e.g. running publish
will first run package
then make
.
For more conceptual details, see the Build Lifecycle guide.
Package
This command will package your application into a platform-specific executable bundle and put the result in a folder. Please note that this does not make a distributable format. To make proper distributables, please use the Make command.
Options
All flags are optional.
--arch
Architecture, e.g. x64
Target architecture to package for. Defaults to the host arch.
--platform
Platform, e.g. mas
Target platform to package for. Defaults to the host platform.
Usage
Make
This command will make distributables for your application based on your Forge config and the parameters you pass in.
If you do not need to repackage your application between Make runs, use the --skip-package
flag.
Options
All flags are optional.
--arch
Architecture, e.g. x64
Target architecture to make for. Defaults to the arch that you're running on (the "host" arch). Allowed values are: "ia32", "x64", "armv7l", "arm64", "universal", or "mips64el". Multiple values should be comma-separated.
--platform
Platform, e.g. mas
Target platform to make for, please note you normally can only target platform X from platform X. This defaults to the platform you're running on (the "host" platform).
--targets
Comma separated list of maker names
Override your make targets for this run. The maker name is the full node module name, e.g. @electron-forge/maker-deb
. By default, the make targets used are the ones available and configured for the given platform.
--skip-package
N/A
Set if you want to skip the packaging step, useful if you are running sequential makes and want to save time. By default, packaging is not skipped.
Usage
Basic usage:
Building for ia32 and x64 architectures:
Publish
This command will attempt to package, make, and publish the Forge application to the publish targets defined in your Forge config.
If you want to verify artifacts from the Make step before publishing, you can use the Dry Run options explained below.
Options
All flags are optional.
--target
Comma separated list of publisher names
Override your publish targets for this run
--dry-run
N/A
Triggers a publish dry run which saves state and doesn't upload anything
--from-dry-run
N/A
Attempts to publish artifacts from any dry runs saved on disk
Usage
Dev commands
Start
This command will launch your app in dev mode with the electron
binary in the given directory (defaults to .
).
If you type rs
(and hit enter) in the same terminal where you ran the start command, the running app will be terminated and restarted.
Forge plugins can override this command to run custom development logic. For example, the Webpack Plugin runs a webpack-dev-server instance to provide live reloading and HMR.
Options
All flags are optional.
--app-path
Path to your app from the working directory
Override the path to the Electron app to launch (defaults to .
)
--enable-logging
N/A
Enable advanced logging. This will log internal Electron things
--run-as-node
N/A
Run the Electron app as a Node.JS script
--inspect-electron
N/A
Triggers inspect mode on Electron to allow debugging the main process
--
extra arguments
Any additional arguments to pass to Electron or the app itself. For example: -- --my-app-argument
Usage
Programmatic usage
The Forge CLI should suit most use cases, but we do expose the @electron-forge/core
package for programmatic command usage.
For more information, see the API documentation.
Last updated