2016-05-17 23:02:54 +00:00
# Environment Variables
2015-11-26 12:37:48 +00:00
2016-04-21 22:39:12 +00:00
> Control application configuration and behavior without changing code.
2016-04-21 22:35:29 +00:00
2016-05-20 21:03:28 +00:00
Certain Electron behaviors are controlled by environment variables because they
are initialized earlier than the command line flags and the app's code.
2015-11-26 12:37:48 +00:00
2016-05-20 21:03:56 +00:00
POSIX shell example:
2015-11-26 12:44:07 +00:00
2017-11-24 10:13:57 +00:00
```sh
2015-11-26 12:44:07 +00:00
$ export ELECTRON_ENABLE_LOGGING=true
$ electron
```
2016-05-20 21:03:56 +00:00
Windows console example:
2015-11-26 12:44:07 +00:00
```powershell
> set ELECTRON_ENABLE_LOGGING=true
> electron
```
2016-09-20 20:58:39 +00:00
## Production Variables
The following environment variables are intended primarily for use at runtime
in packaged Electron applications.
2018-10-18 23:57:28 +00:00
### `NODE_OPTIONS`
Electron includes support for a subset of Node's [`NODE_OPTIONS` ](https://nodejs.org/api/cli.html#cli_node_options_options ). The majority are supported with the exception of those which conflict with Chromium's use of BoringSSL.
Example:
```sh
export NODE_OPTIONS="--no-warnings --max-old-space-size=2048"
```
Unsupported options are:
```sh
--use-bundled-ca
--force-fips
--enable-fips
--openssl-config
--use-openssl-ca
```
`NODE_OPTIONS` are explicitly disallowed in packaged apps.
2016-09-20 20:58:39 +00:00
### `GOOGLE_API_KEY`
2018-10-31 14:49:44 +00:00
You can provide an API key for making requests to Google's geocoding webservice. To do this, place the following code in your main process
2016-09-20 20:58:39 +00:00
file, before opening any browser windows that will make geocoding requests:
```javascript
2016-09-20 21:55:45 +00:00
process.env.GOOGLE_API_KEY = 'YOUR_KEY_HERE'
2016-09-20 20:58:39 +00:00
```
2018-10-31 14:49:44 +00:00
For instructions on how to acquire a Google API key, visit [this page ](https://developers.google.com/maps/documentation/javascript/get-api-key ).
2016-09-20 20:58:39 +00:00
By default, a newly generated Google API key may not be allowed to make
2018-10-31 14:49:44 +00:00
geocoding requests. To enable geocoding requests, visit [this page ](https://developers.google.com/maps/documentation/geocoding/get-api-key ).
2016-09-20 20:58:39 +00:00
2016-10-04 08:39:05 +00:00
### `ELECTRON_NO_ASAR`
2016-10-07 18:03:00 +00:00
Disables ASAR support. This variable is only supported in forked child processes
and spawned child processes that set `ELECTRON_RUN_AS_NODE` .
2016-10-04 08:39:05 +00:00
2016-12-22 17:22:04 +00:00
### `ELECTRON_RUN_AS_NODE`
Starts the process as a normal Node.js process.
### `ELECTRON_NO_ATTACH_CONSOLE` _Windows_
Don't attach to the current console session.
### `ELECTRON_FORCE_WINDOW_MENU_BAR` _Linux_
Don't use the global menu bar on Linux.
2018-10-26 15:36:56 +00:00
### `ELECTRON_TRASH` _Linux_
Set the trash implementation on Linux. Default is `gio` .
Options:
* `gvfs-trash`
* `trash-cli`
* `kioclient5`
* `kioclient`
2016-09-20 20:58:39 +00:00
## Development Variables
The following environment variables are intended primarily for development and
debugging purposes.
2015-11-26 12:37:48 +00:00
2016-05-20 20:58:48 +00:00
### `ELECTRON_ENABLE_LOGGING`
2015-11-26 12:37:48 +00:00
2016-05-20 21:01:08 +00:00
Prints Chrome's internal logging to the console.
2015-11-26 12:37:48 +00:00
2016-05-20 20:58:48 +00:00
### `ELECTRON_LOG_ASAR_READS`
2015-12-23 00:05:14 +00:00
2016-01-21 18:57:50 +00:00
When Electron reads from an ASAR file, log the read offset and file path to
the system `tmpdir` . The resulting file can be provided to the ASAR module
2015-12-23 00:05:14 +00:00
to optimize file ordering.
2016-05-20 20:58:48 +00:00
### `ELECTRON_ENABLE_STACK_DUMPING`
2015-11-26 12:37:48 +00:00
2016-05-20 21:02:10 +00:00
Prints the stack trace to the console when Electron crashes.
2015-11-26 12:37:48 +00:00
2016-05-20 21:01:08 +00:00
This environment variable will not work if the `crashReporter` is started.
2015-11-26 12:37:48 +00:00
2016-05-20 20:58:48 +00:00
### `ELECTRON_DEFAULT_ERROR_MODE` _Windows_
2015-11-26 12:37:48 +00:00
2016-05-20 21:01:08 +00:00
Shows the Windows's crash dialog when Electron crashes.
2015-11-26 12:37:48 +00:00
2016-05-20 21:01:08 +00:00
This environment variable will not work if the `crashReporter` is started.
2018-03-25 04:03:17 +00:00
### `ELECTRON_OVERRIDE_DIST_PATH`
When running from the `electron` package, this variable tells
the `electron` command to use the specified build of Electron instead of
the one downloaded by `npm install` . Usage:
```sh
2018-09-09 01:15:32 +00:00
export ELECTRON_OVERRIDE_DIST_PATH=/Users/username/projects/electron/out/Debug
2018-03-25 04:03:17 +00:00
```