Options to configure packaging.
+A Promise containing the paths to the newly created application bundles.
+By default, the functions are called in parallel (via
+Promise.all
).
+If you need the functions called serially, you can use the serialHooks
utility function:
const { packager, serialHooks } = require('@electron/packager')
packager({
// ...
afterCopy: [serialHooks([
(buildPath, electronVersion, platform, arch, callback) => {
setTimeout(() => {
console.log('first function')
callback()
}, 1000)
},
(buildPath, electronVersion, platform, arch, callback) => {
console.log('second function')
callback()
}
])],
// ...
})
+
+Rest
...serialHookParams: [buildPath: string, electronVersion: string, platform: string, arch: string, callback: HookFunctionErrorCallback] | [targets: TargetDefinition[], callback: HookFunctionErrorCallback]Package your Electron app into OS-specific bundles (.app
, .exe
, etc.) via JavaScript or the command line.
Supported Platforms | +Installation | +Usage | +API | +Contributing | +Support | +Related Apps/Libraries | +FAQ | +Release Notes
+Electron Packager is a command line tool and Node.js library that bundles Electron-based application +source code with a renamed Electron executable and supporting files into folders ready for distribution.
+For creating distributables like installers and Linux packages, consider using either Electron +Forge (which uses Electron Packager +internally), or one of the related Electron tools, which utilizes +Electron Packager-created folders as a basis.
+Note that packaged Electron applications can be relatively large. A zipped, minimal Electron
+application is approximately the same size as the zipped prebuilt binary for a given target
+platform, target arch, and Electron version
+(files named electron-v${version}-${platform}-${arch}.zip
).
Electron Packager is known to run on the following host platforms:
+It generates executables/bundles for the following target platforms:
+win32
, for x86, x86_64, and arm64 architectures)darwin
) / Mac App Store (also known as mas
)* (for x86_64, arm64, and universal architectures)* Note for macOS / Mac App Store target bundles: the .app
bundle can only be signed when building on a host macOS platform.
This module requires Node.js 16.13.0 or higher to run.
+npm install --save-dev @electron/packager
+
+It is not recommended to install @electron/packager
globally.
JavaScript API usage can be found in the API documentation.
+Running Electron Packager from the command line has this basic form:
+npx @electron/packager <sourcedir> <appname> --platform=<platform> --arch=<arch> [optional flags...]
+
+++Note: +
+npx
can be substituted foryarn
ornpm exec
depending on what package manager and +the version you have installed.
This will:
+<out>/<appname>-<platform>-<arch>
(this can be customized via an optional flag)--platform
and --arch
can be omitted, in two cases:
--all
instead, bundles for all valid combinations of target
+platforms/architectures will be created.For an overview of the other optional flags, run electron-packager --help
or see
+usage.txt. For
+detailed descriptions, see the API documentation.
For flags that are structured as objects, you can pass each option as via dot notation as such:
+npx @electron/packager --flag.foo="bar"
# will pass in { flag: { foo: "bar"} } as an option to the Electron Packager API
+
+If appname
is omitted, this will use the name specified by "productName" or "name" in the nearest package.json.
Characters in the Electron app name which are not allowed in all target platforms' filenames
+(e.g., /
), will be replaced by hyphens (-
).
You should be able to launch the app on the platform you built for. If not, check your settings and try again.
+Be careful not to include node_modules
you don't want into your final app. If you put them in
+the devDependencies
section of package.json
, by default none of the modules related to those
+dependencies will be copied in the app bundles. (This behavior can be turned off with the
+prune: false
API option or --no-prune
CLI flag.) In addition, folders like .git
and
+node_modules/.bin
will be ignored by default. You can use --ignore
to ignore files and folders
+via a regular expression (not a glob pattern).
+Examples include --ignore=\.gitignore
or --ignore="\.git(ignore|modules)"
.
Let's assume that you have made an app based on the electron-quick-start repository on a macOS host platform with the following file structure:
+foobar
├── package.json
├── index.html
├── […other files, like the app's LICENSE…]
└── script.js
+
+…and that the following is true:
+@electron/packager
is installed locallyproductName
in package.json
has been set to Foo Bar
electron
module is in the devDependencies
section of package.json
, and set to the exact version of 1.4.15
.npm install
for the Foo Bar
app has been run at least onceWhen one runs the following command for the first time in the foobar
directory:
npx @electron/packager .
+
+@electron/packager
will do the following:
sourcedir
appname
from the productName
in package.json
appVersion
from the version
in package.json
platform
and arch
from the host, in this example, darwin
platform and x64
arch.~/.electron
)Foo Bar.app
Foo Bar.app
in foobar/Foo Bar-darwin-x64/
(since an out
directory was not specified, it used the current working directory)The file structure now looks like:
+foobar
├── Foo Bar-darwin-x64
│ ├── Foo Bar.app
│ │ └── […Mac app contents…]
│ ├── LICENSE [the Electron license]
│ └── version
├── […other application bundles, like "Foo Bar-win32-x64" (sans quotes)…]
├── package.json
├── index.html
├── […other files, like the app's LICENSE…]
└── script.js
+
+The Foo Bar.app
folder generated can be executed by a system running macOS, which will start the packaged Electron app. This is also true of the Windows x64 build on a system running a new enough version of Windows for a 64-bit system (via Foo Bar-win32-x64/Foo Bar.exe
), and so on.
Windows:
+macOS:
+Linux:
+These Node modules utilize Electron Packager API hooks:
+Options passed to the packager()
function.
Optional
afterFunctions to be called after your app directory has been packaged into an .asar file.
+Note: afterAsar
will only be called if the asar option is set.
Optional
afterFunctions to be called after the packaged application has been moved to the final directory.
+Optional
afterFunctions to be called after your app directory has been copied to a temporary directory.
+Note: afterCopy
will not be called if the prebuiltAsar option is set.
Optional
afterFunctions to be called after the files specified in the extraResource option have been copied.
+Optional
afterFunctions to be called after the prebuilt Electron binary has been extracted to a temporary directory.
+Optional
afterFunctions to be called after the final matrix of platform/arch combination is determined. Use this to +learn what archs/platforms packager is targetting when you pass "all" as a value.
+Optional
afterOptional
afterFunctions to be called after Node module pruning has been applied to the application.
+Note: None of these functions will be called if the prune option is false
or
+the prebuiltAsar option is set.
Optional
allOptional
appOptional
appThe human-readable copyright line for the app. Maps to the LegalCopyright
metadata
+property on Windows, and NSHumanReadableCopyright
on macOS.
Optional
appThe release version of the application.
+By default the version
property in the package.json
is used, but it can be overridden
+with this argument. If neither are provided, the version of Electron will be used. Maps
+to the ProductVersion
metadata property on Windows, and CFBundleShortVersionString
+on macOS.
The target system architecture(s) to build for.
+Not required if the all option is set. If arch
is set to all
, all supported
+architectures for the target platforms specified by platform will be built.
+Arbitrary combinations of individual architectures are also supported via a comma-delimited
+string or array of strings. The non-all
values correspond to the architecture names used
+by Electron releases. This value
+is not restricted to the official set if [[download|download.mirrorOptions
]] is set.
Defaults to the arch of the host computer running Electron Packager.
+Arch values for the official prebuilt Electron binaries:
+ia32
x64
armv7l
arm64
(Linux: Electron 1.8.0 and above; Windows: 6.0.8 and above; macOS: 11.0.0-beta.1 and above)mips64el
(Electron 1.8.2-beta.5 to 1.8.8)Optional
asarWhether to package the application's source code into an archive, using Electron's
+archive format. Reasons why you may want to enable
+this feature include mitigating issues around long path names on Windows, slightly speeding
+up require
, and concealing your source code from cursory inspection. When the value
+is true
, it passes the default configuration to the asar
module. The configuration
+values can be customized when the value is an Object
. Supported sub-options include, but
+are not limited to:
ordering
(string): A path to an ordering file for packing files. An explanation can be
+found on the Atom issue tracker.unpack
(string): A glob expression,
+when specified, unpacks the file with matching names to the app.asar.unpacked
directory.unpackDir
(string): Unpacks the dir to the app.asar.unpacked
directory whose names
+exactly or pattern match this string. The asar.unpackDir
is relative to dir.Defaults to false
.
Some examples:
+asar.unpackDir = 'sub_dir'
will unpack the directory /<dir>/sub_dir
asar.unpackDir = path.join('**', '{sub_dir1/sub_sub_dir,sub_dir2}', '*')
will unpack the directories /<dir>/sub_dir1/sub_sub_dir
and /<dir>/sub_dir2
, but it will not include their subdirectories.asar.unpackDir = path.join('**', '{sub_dir1/sub_sub_dir,sub_dir2}', '**')
will unpack the subdirectories of the directories /<dir>/sub_dir1/sub_sub_dir
and /<dir>/sub_dir2
.asar.unpackDir = path.join('**', '{sub_dir1/sub_sub_dir,sub_dir2}', '**', '*')
will unpack the directories /<dir>/sub_dir1/sub_sub_dir
and /<dir>/sub_dir2
and their subdirectories.Note: asar
will have no effect if the prebuiltAsar option is set.
Optional
beforeFunctions to be called before your app directory is packaged into an .asar file.
+Note: beforeAsar
will only be called if the asar option is set.
Optional
beforeFunctions to be called before your app directory is copied to a temporary directory.
+Note: beforeCopy
will not be called if the prebuiltAsar option is set.
Optional
beforeFunctions to be called before the files specified in the extraResource option are copied.
+Optional
buildThe build version of the application. Defaults to the value of the appVersion option.
+Maps to the FileVersion
metadata property on Windows, and CFBundleVersion
on macOS.
Optional
derefWhether symlinks should be dereferenced during the copying of the application source.
+Defaults to true
.
Note: derefSymlinks
will have no effect if the prebuiltAsar option is set.
The source directory.
+Optional
downloadIf present, passes custom options to @electron/get
. See
+the module for option descriptions, proxy support, and defaults. Supported parameters
+include, but are not limited to:
cacheRoot
(string): The directory where prebuilt, pre-packaged Electron downloads are cached.mirrorOptions
(Object): Options to override the default Electron download location.Note: download
sub-options will have no effect if the electronZipDir option is set.
Optional
electronThe Electron version with which the app is built (without the leading 'v') - for example,
+1.4.13
. See Electron
+releases for valid versions. If omitted, it
electron
or electron-nightly
package.json
in either devDependencies
or dependencies
.Optional
electronThe local path to a directory containing Electron ZIP files for Electron Packager to unzip, instead +of downloading them. The ZIP filenames should be in the same format as the ones downloaded from the +Electron releases site.
+Note: Setting this option prevents the download sub-options from being used, as +the functionality gets skipped over.
+Optional
executableOptional
extraOne or more files to be copied directly into the app's Contents/Resources
directory for
+macOS target platforms, and the resources
directory for other target platforms. The
+resources directory can be referenced in the packaged app via the
+process.resourcesPath
value.
Optional
iconThe local path to the icon file, if the target platform supports setting embedding an icon.
+Currently you must look for conversion tools in order to supply an icon in the format required by the platform:
+.icns
.ico
(See the readme for details on non-Windows platforms)icon
option in the BrowserWindow
constructor.
+Please note that you need to use a PNG, and not the macOS or Windows icon formats, in order for it
+to show up in the dock/window list. Setting the icon in the file manager is not currently supported.If the file extension is omitted, it is auto-completed to the correct extension based on the
+platform, including when [[platform|platform: 'all'
]] is in effect.
Optional
ignoreOne or more additional regular expression +patterns which specify which files to ignore when copying files to create the app bundle(s). The +regular expressions are matched against the absolute path of a given file/directory to be copied.
+Please note that glob patterns will not work.
+The following paths are always ignored (when you aren't using an IgnoreFunction):
+node_modules/.bin
node_modules/electron
node_modules/electron-nightly
.git
.o
and .obj
Note: Node modules specified in devDependencies
are ignored by default, via the
+prune option.
Note: ignore
will have no effect if the prebuiltAsar option is set.
Optional
junkIgnores system junk files when copying the Electron app, +regardless of the ignore option.
+Note: junk
will have no effect if the prebuiltAsar option is set.
Optional
nameThe application name. If omitted, it will use the productName
or name
value from the
+nearest package.json
.
Regardless of source, characters in the Electron app name which are not allowed in all target
+platforms' filenames (e.g., /
), will be replaced by hyphens (-
).
Optional
osxUsed to provide custom options to the internal call to @electron/universal
when building a macOS
+app with the target architecture of "universal". Unused otherwise, providing a value does not imply
+a universal app is built.
Optional
outThe base directory where the finished package(s) are created.
+Defaults to the current working directory.
+Optional
overwriteWhether to replace an already existing output directory for a given platform (true
) or
+skip recreating it (false
). Defaults to false
.
The target platform(s) to build for.
+Not required if the all option is set. If platform
is set to all
, all officially
+supported target platforms for the target architectures specified by the arch option
+will be built. Arbitrary combinations of individual platforms are also supported via a
+comma-delimited string or array of strings.
The official non-all
values correspond to the platform names used by Electron
+releases. This value is not restricted to
+the official set if [[download|`download.mirrorOptions]] is set.
Defaults to the platform of the host computer running Electron Packager.
+Platform values for the official prebuilt Electron binaries:
+darwin
(macOS)linux
mas
(macOS, specifically for submitting to the Mac App Store)win32
Optional
prebuiltThe path to a prebuilt ASAR file.
+Note: Setting this option prevents the following options from being used, as the functionality +gets skipped over:
+Optional
pruneWalks the node_modules
dependency tree to remove all of the packages specified in the
+devDependencies
section of package.json
from the outputted Electron app.
Defaults to true
.
Note: prune
will have no effect if the prebuiltAsar option is set.
Optional
quietIf true
, disables printing informational and warning messages to the console when
+packaging the application. This does not disable errors.
Defaults to false
.
Optional
tmpdirThe base directory to use as a temporary directory. Set to false
to disable use of a
+temporary directory. Defaults to the system's temporary directory.
Optional
win32metadataApplication metadata to embed into the Windows executable.
+Optional
windowsIf present, signs Windows binary files.
+When the value is true
, pass default configuration to the signing module. See
+@electron/windows-sign for sub-option descriptions and
+their defaults.
Optional
appThe application category type, as shown in the Finder via View → Arrange by Application +Category when viewing the Applications directory.
+For example, app-category-type=public.app-category.developer-tools
will set the
+application category to Developer Tools.
Valid values are listed in Apple's documentation.
+Optional
darwinForces support for Mojave (macOS 10.14) dark mode in your packaged app. This sets the
+NSRequiresAquaSystemAppearance
key to false
in your app's Info.plist
. For more information,
+see the Electron documentation
+and the Apple developer documentation.
Optional
extendWhen the value is a string, specifies the filename of a plist
file. Its contents are merged
+into all the Helper apps' Info.plist
files.
+When the value is an Object
, it specifies an already-parsed plist
data structure that is
+merged into all the Helper apps' Info.plist
files.
Entries from extendHelperInfo
override entries in the helper apps' Info.plist
file supplied by
electron
or electron-nightly
, but are overridden by other
+options such as appVersion or appBundleId.Optional
extendWhen the value is a string, specifies the filename of a plist
file. Its contents are merged
+into the app's Info.plist
.
+When the value is an Object
, it specifies an already-parsed plist
data structure that is
+merged into the app's Info.plist
.
Entries from extendInfo
override entries in the base Info.plist
file supplied by
electron
or electron-nightly
, but are overridden by other
+options such as appVersion or appBundleId.Optional
helperThe bundle identifier to use in the application helper's Info.plist
.
Optional
osxIf present, notarizes macOS target apps when the host platform is macOS and Xcode is installed.
+See @electron/notarize
+for option descriptions, such as how to use appleIdPassword
safely or obtain an API key.
Requires the osxSign option to be set.
+Optional
osxIf present, signs macOS target apps when the host platform is macOS and Xcode is installed.
+When the value is true
, pass default configuration to the signing module. See
+@electron/osx-sign for sub-option descriptions and
+their defaults. Options include, but are not limited to:
identity
(string): The identity used when signing the package via codesign
.binaries
(arrayOptional
protocolsThe URL protocol schemes associated with the Electron app.
+Optional
usageHuman-readable descriptions of how the Electron app uses certain macOS features. These are displayed +in the App Store. A non-exhaustive list of available properties:
+Camera
- required for media access API usage in macOS CatalinaMicrophone
- required for media access API usage in macOS CatalinaValid properties are the Cocoa keys for MacOS
+of the pattern NS(.*)UsageDescription
, where the captured group is the key to use.
Example:
+{
usageDescription: {
Camera: 'Needed for video calls',
Microphone: 'Needed for voice calls'
}
}
+
+Optional
afterFunctions to be called after your app directory has been packaged into an .asar file.
+Note: afterAsar
will only be called if the asar option is set.
Optional
afterFunctions to be called after the packaged application has been moved to the final directory.
+Optional
afterFunctions to be called after your app directory has been copied to a temporary directory.
+Note: afterCopy
will not be called if the prebuiltAsar option is set.
Optional
afterFunctions to be called after the files specified in the extraResource option have been copied.
+Optional
afterFunctions to be called after the prebuilt Electron binary has been extracted to a temporary directory.
+Optional
afterFunctions to be called after the final matrix of platform/arch combination is determined. Use this to +learn what archs/platforms packager is targetting when you pass "all" as a value.
+Optional
afterOptional
afterFunctions to be called after Node module pruning has been applied to the application.
+Note: None of these functions will be called if the prune option is false
or
+the prebuiltAsar option is set.
Optional
allOptional
appOptional
appThe human-readable copyright line for the app. Maps to the LegalCopyright
metadata
+property on Windows, and NSHumanReadableCopyright
on macOS.
Optional
appThe release version of the application.
+By default the version
property in the package.json
is used, but it can be overridden
+with this argument. If neither are provided, the version of Electron will be used. Maps
+to the ProductVersion
metadata property on Windows, and CFBundleShortVersionString
+on macOS.
Optional
asarWhether to package the application's source code into an archive, using Electron's
+archive format. Reasons why you may want to enable
+this feature include mitigating issues around long path names on Windows, slightly speeding
+up require
, and concealing your source code from cursory inspection. When the value
+is true
, it passes the default configuration to the asar
module. The configuration
+values can be customized when the value is an Object
. Supported sub-options include, but
+are not limited to:
ordering
(string): A path to an ordering file for packing files. An explanation can be
+found on the Atom issue tracker.unpack
(string): A glob expression,
+when specified, unpacks the file with matching names to the app.asar.unpacked
directory.unpackDir
(string): Unpacks the dir to the app.asar.unpacked
directory whose names
+exactly or pattern match this string. The asar.unpackDir
is relative to dir.Defaults to false
.
Some examples:
+asar.unpackDir = 'sub_dir'
will unpack the directory /<dir>/sub_dir
asar.unpackDir = path.join('**', '{sub_dir1/sub_sub_dir,sub_dir2}', '*')
will unpack the directories /<dir>/sub_dir1/sub_sub_dir
and /<dir>/sub_dir2
, but it will not include their subdirectories.asar.unpackDir = path.join('**', '{sub_dir1/sub_sub_dir,sub_dir2}', '**')
will unpack the subdirectories of the directories /<dir>/sub_dir1/sub_sub_dir
and /<dir>/sub_dir2
.asar.unpackDir = path.join('**', '{sub_dir1/sub_sub_dir,sub_dir2}', '**', '*')
will unpack the directories /<dir>/sub_dir1/sub_sub_dir
and /<dir>/sub_dir2
and their subdirectories.Note: asar
will have no effect if the prebuiltAsar option is set.
Optional
beforeFunctions to be called before your app directory is packaged into an .asar file.
+Note: beforeAsar
will only be called if the asar option is set.
Optional
beforeFunctions to be called before your app directory is copied to a temporary directory.
+Note: beforeCopy
will not be called if the prebuiltAsar option is set.
Optional
beforeFunctions to be called before the files specified in the extraResource option are copied.
+Optional
buildThe build version of the application. Defaults to the value of the appVersion option.
+Maps to the FileVersion
metadata property on Windows, and CFBundleVersion
on macOS.
Optional
derefWhether symlinks should be dereferenced during the copying of the application source.
+Defaults to true
.
Note: derefSymlinks
will have no effect if the prebuiltAsar option is set.
The source directory.
+Optional
downloadIf present, passes custom options to @electron/get
. See
+the module for option descriptions, proxy support, and defaults. Supported parameters
+include, but are not limited to:
cacheRoot
(string): The directory where prebuilt, pre-packaged Electron downloads are cached.mirrorOptions
(Object): Options to override the default Electron download location.Note: download
sub-options will have no effect if the electronZipDir option is set.
Optional
electronThe Electron version with which the app is built (without the leading 'v') - for example,
+1.4.13
. See Electron
+releases for valid versions. If omitted, it
electron
or electron-nightly
package.json
in either devDependencies
or dependencies
.Optional
electronThe local path to a directory containing Electron ZIP files for Electron Packager to unzip, instead +of downloading them. The ZIP filenames should be in the same format as the ones downloaded from the +Electron releases site.
+Note: Setting this option prevents the download sub-options from being used, as +the functionality gets skipped over.
+Optional
executableOptional
extraOne or more files to be copied directly into the app's Contents/Resources
directory for
+macOS target platforms, and the resources
directory for other target platforms. The
+resources directory can be referenced in the packaged app via the
+process.resourcesPath
value.
Optional
iconThe local path to the icon file, if the target platform supports setting embedding an icon.
+Currently you must look for conversion tools in order to supply an icon in the format required by the platform:
+.icns
.ico
(See the readme for details on non-Windows platforms)icon
option in the BrowserWindow
constructor.
+Please note that you need to use a PNG, and not the macOS or Windows icon formats, in order for it
+to show up in the dock/window list. Setting the icon in the file manager is not currently supported.If the file extension is omitted, it is auto-completed to the correct extension based on the
+platform, including when [[platform|platform: 'all'
]] is in effect.
Optional
ignoreOne or more additional regular expression +patterns which specify which files to ignore when copying files to create the app bundle(s). The +regular expressions are matched against the absolute path of a given file/directory to be copied.
+Please note that glob patterns will not work.
+The following paths are always ignored (when you aren't using an IgnoreFunction):
+node_modules/.bin
node_modules/electron
node_modules/electron-nightly
.git
.o
and .obj
Note: Node modules specified in devDependencies
are ignored by default, via the
+prune option.
Note: ignore
will have no effect if the prebuiltAsar option is set.
Optional
junkIgnores system junk files when copying the Electron app, +regardless of the ignore option.
+Note: junk
will have no effect if the prebuiltAsar option is set.
Optional
nameThe application name. If omitted, it will use the productName
or name
value from the
+nearest package.json
.
Regardless of source, characters in the Electron app name which are not allowed in all target
+platforms' filenames (e.g., /
), will be replaced by hyphens (-
).
Optional
osxUsed to provide custom options to the internal call to @electron/universal
when building a macOS
+app with the target architecture of "universal". Unused otherwise, providing a value does not imply
+a universal app is built.
Optional
outThe base directory where the finished package(s) are created.
+Defaults to the current working directory.
+Optional
overwriteWhether to replace an already existing output directory for a given platform (true
) or
+skip recreating it (false
). Defaults to false
.
Optional
prebuiltThe path to a prebuilt ASAR file.
+Note: Setting this option prevents the following options from being used, as the functionality +gets skipped over:
+Optional
pruneWalks the node_modules
dependency tree to remove all of the packages specified in the
+devDependencies
section of package.json
from the outputted Electron app.
Defaults to true
.
Note: prune
will have no effect if the prebuiltAsar option is set.
Optional
quietIf true
, disables printing informational and warning messages to the console when
+packaging the application. This does not disable errors.
Defaults to false
.
Optional
tmpdirThe base directory to use as a temporary directory. Set to false
to disable use of a
+temporary directory. Defaults to the system's temporary directory.
Optional
win32metadataApplication metadata to embed into the Windows executable.
+Optional
windowsIf present, signs Windows binary files.
+When the value is true
, pass default configuration to the signing module. See
+@electron/windows-sign for sub-option descriptions and
+their defaults.
Optional
appThe application category type, as shown in the Finder via View → Arrange by Application +Category when viewing the Applications directory.
+For example, app-category-type=public.app-category.developer-tools
will set the
+application category to Developer Tools.
Valid values are listed in Apple's documentation.
+Optional
darwinForces support for Mojave (macOS 10.14) dark mode in your packaged app. This sets the
+NSRequiresAquaSystemAppearance
key to false
in your app's Info.plist
. For more information,
+see the Electron documentation
+and the Apple developer documentation.
Optional
extendWhen the value is a string, specifies the filename of a plist
file. Its contents are merged
+into all the Helper apps' Info.plist
files.
+When the value is an Object
, it specifies an already-parsed plist
data structure that is
+merged into all the Helper apps' Info.plist
files.
Entries from extendHelperInfo
override entries in the helper apps' Info.plist
file supplied by
electron
or electron-nightly
, but are overridden by other
+options such as appVersion or appBundleId.Optional
extendWhen the value is a string, specifies the filename of a plist
file. Its contents are merged
+into the app's Info.plist
.
+When the value is an Object
, it specifies an already-parsed plist
data structure that is
+merged into the app's Info.plist
.
Entries from extendInfo
override entries in the base Info.plist
file supplied by
electron
or electron-nightly
, but are overridden by other
+options such as appVersion or appBundleId.Optional
helperThe bundle identifier to use in the application helper's Info.plist
.
Optional
osxIf present, notarizes macOS target apps when the host platform is macOS and Xcode is installed.
+See @electron/notarize
+for option descriptions, such as how to use appleIdPassword
safely or obtain an API key.
Requires the osxSign option to be set.
+Optional
osxIf present, signs macOS target apps when the host platform is macOS and Xcode is installed.
+When the value is true
, pass default configuration to the signing module. See
+@electron/osx-sign for sub-option descriptions and
+their defaults. Options include, but are not limited to:
identity
(string): The identity used when signing the package via codesign
.binaries
(arrayOptional
protocolsThe URL protocol schemes associated with the Electron app.
+Optional
usageHuman-readable descriptions of how the Electron app uses certain macOS features. These are displayed +in the App Store. A non-exhaustive list of available properties:
+Camera
- required for media access API usage in macOS CatalinaMicrophone
- required for media access API usage in macOS CatalinaValid properties are the Cocoa keys for MacOS
+of the pattern NS(.*)UsageDescription
, where the captured group is the key to use.
Example:
+{
usageDescription: {
Camera: 'Needed for video calls',
Microphone: 'Needed for voice calls'
}
}
+
+Defines URL protocol schemes to be used on macOS.
+The descriptive name. Maps to the CFBundleURLName
metadata property.
One or more protocol schemes associated with the app. For example, specifying myapp
+would cause URLs such as myapp://path
to be opened with the app. Maps to the
+CFBundleURLSchemes
metadata property.
Options passed to the packager()
function.
Optional
afterFunctions to be called after your app directory has been packaged into an .asar file.
+Note: afterAsar
will only be called if the asar option is set.
Optional
afterFunctions to be called after the packaged application has been moved to the final directory.
+Optional
afterFunctions to be called after your app directory has been copied to a temporary directory.
+Note: afterCopy
will not be called if the prebuiltAsar option is set.
Optional
afterFunctions to be called after the files specified in the extraResource option have been copied.
+Optional
afterFunctions to be called after the prebuilt Electron binary has been extracted to a temporary directory.
+Optional
afterFunctions to be called after the final matrix of platform/arch combination is determined. Use this to +learn what archs/platforms packager is targetting when you pass "all" as a value.
+Optional
afterOptional
afterFunctions to be called after Node module pruning has been applied to the application.
+Note: None of these functions will be called if the prune option is false
or
+the prebuiltAsar option is set.
Optional
allOptional
appOptional
appThe human-readable copyright line for the app. Maps to the LegalCopyright
metadata
+property on Windows, and NSHumanReadableCopyright
on macOS.
Optional
appThe release version of the application.
+By default the version
property in the package.json
is used, but it can be overridden
+with this argument. If neither are provided, the version of Electron will be used. Maps
+to the ProductVersion
metadata property on Windows, and CFBundleShortVersionString
+on macOS.
Optional
archThe target system architecture(s) to build for.
+Not required if the all option is set. If arch
is set to all
, all supported
+architectures for the target platforms specified by platform will be built.
+Arbitrary combinations of individual architectures are also supported via a comma-delimited
+string or array of strings. The non-all
values correspond to the architecture names used
+by Electron releases. This value
+is not restricted to the official set if [[download|download.mirrorOptions
]] is set.
Defaults to the arch of the host computer running Electron Packager.
+Arch values for the official prebuilt Electron binaries:
+ia32
x64
armv7l
arm64
(Linux: Electron 1.8.0 and above; Windows: 6.0.8 and above; macOS: 11.0.0-beta.1 and above)mips64el
(Electron 1.8.2-beta.5 to 1.8.8)Optional
asarWhether to package the application's source code into an archive, using Electron's
+archive format. Reasons why you may want to enable
+this feature include mitigating issues around long path names on Windows, slightly speeding
+up require
, and concealing your source code from cursory inspection. When the value
+is true
, it passes the default configuration to the asar
module. The configuration
+values can be customized when the value is an Object
. Supported sub-options include, but
+are not limited to:
ordering
(string): A path to an ordering file for packing files. An explanation can be
+found on the Atom issue tracker.unpack
(string): A glob expression,
+when specified, unpacks the file with matching names to the app.asar.unpacked
directory.unpackDir
(string): Unpacks the dir to the app.asar.unpacked
directory whose names
+exactly or pattern match this string. The asar.unpackDir
is relative to dir.Defaults to false
.
Some examples:
+asar.unpackDir = 'sub_dir'
will unpack the directory /<dir>/sub_dir
asar.unpackDir = path.join('**', '{sub_dir1/sub_sub_dir,sub_dir2}', '*')
will unpack the directories /<dir>/sub_dir1/sub_sub_dir
and /<dir>/sub_dir2
, but it will not include their subdirectories.asar.unpackDir = path.join('**', '{sub_dir1/sub_sub_dir,sub_dir2}', '**')
will unpack the subdirectories of the directories /<dir>/sub_dir1/sub_sub_dir
and /<dir>/sub_dir2
.asar.unpackDir = path.join('**', '{sub_dir1/sub_sub_dir,sub_dir2}', '**', '*')
will unpack the directories /<dir>/sub_dir1/sub_sub_dir
and /<dir>/sub_dir2
and their subdirectories.Note: asar
will have no effect if the prebuiltAsar option is set.
Optional
beforeFunctions to be called before your app directory is packaged into an .asar file.
+Note: beforeAsar
will only be called if the asar option is set.
Optional
beforeFunctions to be called before your app directory is copied to a temporary directory.
+Note: beforeCopy
will not be called if the prebuiltAsar option is set.
Optional
beforeFunctions to be called before the files specified in the extraResource option are copied.
+Optional
buildThe build version of the application. Defaults to the value of the appVersion option.
+Maps to the FileVersion
metadata property on Windows, and CFBundleVersion
on macOS.
Optional
derefWhether symlinks should be dereferenced during the copying of the application source.
+Defaults to true
.
Note: derefSymlinks
will have no effect if the prebuiltAsar option is set.
The source directory.
+Optional
downloadIf present, passes custom options to @electron/get
. See
+the module for option descriptions, proxy support, and defaults. Supported parameters
+include, but are not limited to:
cacheRoot
(string): The directory where prebuilt, pre-packaged Electron downloads are cached.mirrorOptions
(Object): Options to override the default Electron download location.Note: download
sub-options will have no effect if the electronZipDir option is set.
Optional
electronThe Electron version with which the app is built (without the leading 'v') - for example,
+1.4.13
. See Electron
+releases for valid versions. If omitted, it
electron
or electron-nightly
package.json
in either devDependencies
or dependencies
.Optional
electronThe local path to a directory containing Electron ZIP files for Electron Packager to unzip, instead +of downloading them. The ZIP filenames should be in the same format as the ones downloaded from the +Electron releases site.
+Note: Setting this option prevents the download sub-options from being used, as +the functionality gets skipped over.
+Optional
executableOptional
extraOne or more files to be copied directly into the app's Contents/Resources
directory for
+macOS target platforms, and the resources
directory for other target platforms. The
+resources directory can be referenced in the packaged app via the
+process.resourcesPath
value.
Optional
iconThe local path to the icon file, if the target platform supports setting embedding an icon.
+Currently you must look for conversion tools in order to supply an icon in the format required by the platform:
+.icns
.ico
(See the readme for details on non-Windows platforms)icon
option in the BrowserWindow
constructor.
+Please note that you need to use a PNG, and not the macOS or Windows icon formats, in order for it
+to show up in the dock/window list. Setting the icon in the file manager is not currently supported.If the file extension is omitted, it is auto-completed to the correct extension based on the
+platform, including when [[platform|platform: 'all'
]] is in effect.
Optional
ignoreOne or more additional regular expression +patterns which specify which files to ignore when copying files to create the app bundle(s). The +regular expressions are matched against the absolute path of a given file/directory to be copied.
+Please note that glob patterns will not work.
+The following paths are always ignored (when you aren't using an IgnoreFunction):
+node_modules/.bin
node_modules/electron
node_modules/electron-nightly
.git
.o
and .obj
Note: Node modules specified in devDependencies
are ignored by default, via the
+prune option.
Note: ignore
will have no effect if the prebuiltAsar option is set.
Optional
junkIgnores system junk files when copying the Electron app, +regardless of the ignore option.
+Note: junk
will have no effect if the prebuiltAsar option is set.
Optional
nameThe application name. If omitted, it will use the productName
or name
value from the
+nearest package.json
.
Regardless of source, characters in the Electron app name which are not allowed in all target
+platforms' filenames (e.g., /
), will be replaced by hyphens (-
).
Optional
osxUsed to provide custom options to the internal call to @electron/universal
when building a macOS
+app with the target architecture of "universal". Unused otherwise, providing a value does not imply
+a universal app is built.
Optional
outThe base directory where the finished package(s) are created.
+Defaults to the current working directory.
+Optional
overwriteWhether to replace an already existing output directory for a given platform (true
) or
+skip recreating it (false
). Defaults to false
.
Optional
platformThe target platform(s) to build for.
+Not required if the all option is set. If platform
is set to all
, all officially
+supported target platforms for the target architectures specified by the arch option
+will be built. Arbitrary combinations of individual platforms are also supported via a
+comma-delimited string or array of strings.
The official non-all
values correspond to the platform names used by Electron
+releases. This value is not restricted to
+the official set if [[download|`download.mirrorOptions]] is set.
Defaults to the platform of the host computer running Electron Packager.
+Platform values for the official prebuilt Electron binaries:
+darwin
(macOS)linux
mas
(macOS, specifically for submitting to the Mac App Store)win32
Optional
prebuiltThe path to a prebuilt ASAR file.
+Note: Setting this option prevents the following options from being used, as the functionality +gets skipped over:
+Optional
pruneWalks the node_modules
dependency tree to remove all of the packages specified in the
+devDependencies
section of package.json
from the outputted Electron app.
Defaults to true
.
Note: prune
will have no effect if the prebuiltAsar option is set.
Optional
quietIf true
, disables printing informational and warning messages to the console when
+packaging the application. This does not disable errors.
Defaults to false
.
Optional
tmpdirThe base directory to use as a temporary directory. Set to false
to disable use of a
+temporary directory. Defaults to the system's temporary directory.
Optional
win32metadataApplication metadata to embed into the Windows executable.
+Optional
windowsIf present, signs Windows binary files.
+When the value is true
, pass default configuration to the signing module. See
+@electron/windows-sign for sub-option descriptions and
+their defaults.
Optional
appThe application category type, as shown in the Finder via View → Arrange by Application +Category when viewing the Applications directory.
+For example, app-category-type=public.app-category.developer-tools
will set the
+application category to Developer Tools.
Valid values are listed in Apple's documentation.
+Optional
darwinForces support for Mojave (macOS 10.14) dark mode in your packaged app. This sets the
+NSRequiresAquaSystemAppearance
key to false
in your app's Info.plist
. For more information,
+see the Electron documentation
+and the Apple developer documentation.
Optional
extendWhen the value is a string, specifies the filename of a plist
file. Its contents are merged
+into all the Helper apps' Info.plist
files.
+When the value is an Object
, it specifies an already-parsed plist
data structure that is
+merged into all the Helper apps' Info.plist
files.
Entries from extendHelperInfo
override entries in the helper apps' Info.plist
file supplied by
electron
or electron-nightly
, but are overridden by other
+options such as appVersion or appBundleId.Optional
extendWhen the value is a string, specifies the filename of a plist
file. Its contents are merged
+into the app's Info.plist
.
+When the value is an Object
, it specifies an already-parsed plist
data structure that is
+merged into the app's Info.plist
.
Entries from extendInfo
override entries in the base Info.plist
file supplied by
electron
or electron-nightly
, but are overridden by other
+options such as appVersion or appBundleId.Optional
helperThe bundle identifier to use in the application helper's Info.plist
.
Optional
osxIf present, notarizes macOS target apps when the host platform is macOS and Xcode is installed.
+See @electron/notarize
+for option descriptions, such as how to use appleIdPassword
safely or obtain an API key.
Requires the osxSign option to be set.
+Optional
osxIf present, signs macOS target apps when the host platform is macOS and Xcode is installed.
+When the value is true
, pass default configuration to the signing module. See
+@electron/osx-sign for sub-option descriptions and
+their defaults. Options include, but are not limited to:
identity
(string): The identity used when signing the package via codesign
.binaries
(arrayOptional
protocolsThe URL protocol schemes associated with the Electron app.
+Optional
usageHuman-readable descriptions of how the Electron app uses certain macOS features. These are displayed +in the App Store. A non-exhaustive list of available properties:
+Camera
- required for media access API usage in macOS CatalinaMicrophone
- required for media access API usage in macOS CatalinaValid properties are the Cocoa keys for MacOS
+of the pattern NS(.*)UsageDescription
, where the captured group is the key to use.
Example:
+{
usageDescription: {
Camera: 'Needed for video calls',
Microphone: 'Needed for voice calls'
}
}
+
+A collection of application metadata to embed into the Windows executable.
+Optional
CompanyDefaults to the author
name from the nearest package.json
.
Optional
FileDefaults to either productName
or name
from the nearest package.json
.
Optional
InternalDefaults to either productName
or name
from the nearest package.json
.
Optional
OriginalDefaults to the renamed Electron .exe
file.
Optional
ProductDefaults to either productName
or name
from the nearest package.json
.
Optional
application-Path to a local manifest file.
+See MSDN for more details.
+Optional
requested-See MSDN for details.
+See the documentation for @electron/windows-sign
+for details.
Optional
continueA function that is called on the completion of a packaging stage.
+By default, the functions are called in parallel (via
+Promise.all
).
+If you need the functions called serially, there is a utility function provided. Please note that
+callback-style functions are not supported by serialHooks
. For example:
const packager = require('@electron/packager')
* const { serialHooks } = require('@electron/packager/src/hooks')
packager({
// ...
afterCopy: [serialHooks([
(buildPath, electronVersion, platform, arch) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log('first function')
resolve()
}, 1000)
})
},
(buildPath, electronVersion, platform, arch) => {
console.log('second function')
}
])],
// ...
})
+
+For real-world examples of HookFunction
s, see the list of related
+plugins.
Optional
err: Error | nullA predicate function that, given an absolute file path
, returns true
if the file should be
+ignored, or false
if the file should be kept. This does not use any of the default ignored
+files/directories listed for the ignore option.
Architectures that have been supported by the official Electron prebuilt binaries, past +and present.
+Platforms that have been supported by the official Electron prebuilt binaries, past and present.
+See the documentation for @electron/osx-sign
for details.
See the documentation for @electron/universal
+for details.
Architecture values that we actually support out of the box (not considering unofficial values provided in
+download.mirrorOptions
).
Platform values that we actually support out of the box (not considering unofficial values provided in
+download.mirrorOptions
).
Bundles Electron-based application source code with a renamed/customized Electron executable and +its supporting files into folders ready for distribution.
+Briefly, this function:
++- finds or downloads the correct release of Electron
+- uses that version of Electron to create a app in
+
+<out>/<appname>-<platform>-<arch>
Short example:
+ +