In this section, we will learn Electron the environment variables in 060b8e06d57877. Environment variables are mainly used to control application configuration and behavior without changing the code. Certain Electron behaviors are controlled by it, so they are initialized earlier than the command line flags and application code.

We can divide environment variables into two types: production environment-related variables and development environment-related variables.

Production environment related variables

Variables related to the production environment are often used when the packaged Electron application is running. There are the following:

  • NODE_OPTIONS : Electron includes support for Node NODE_OPTIONS . Most of them are supported except for the Chromium using BoringSSL
  • GOOGLE_API_KEY : Electron contains a hard-coded API password that is used to send requests web
  • ELECTRON_NO_ASAR : Disable ASAR support. This variable is only supported in the derived child process and derived child process of set
  • ELECTRON_RUN_AS_NODE : Start as a normal Node.js process. In this mode, we can pass the cli Node.js Node.js executable file, except for the following flags:
--openssl-config
--use-bundled-ca
--use-openssl-ca
--force-fips
--enable-fips
  • ELECTRON_NO_ATTACH_CONSOLE : Do not attach to the current console session.
  • ELECTRON_FORCE_WINDOW_MENU_BAR : Do not use the global menu bar Linux
  • ELECTRON_TRASH : Set the garbage collection implementation Linux gio .

Development environment related variables

Development environment related variables are often used for development and debugging purposes. There are the following:

  • ELECTRON_ENABLE_LOGGING : Chrome the internal log records of 060b8e06d57a8b to the console.
  • ELECTRON_LOG_ASAR_READS : When Electron read from the ASAR file, we need to read the offset and file path record to the system timdir . Provide the result file to the ASAR module to optimize the file sorting.
  • ELECTRON_ENABLE_STACK_DUMPING : When Electron crashes, print the stack trace to the console. If crashReporter has been started, this environment variable will not work.
  • ELECTRON_DEFAULT_ERROR_MODE : When ELectron show crash Windows crash dialog. If crashReporter has been started, this environment variable will not work.
  • ELECTRON_OVERRIDE_DIST_PATH : When the electron package runs, this variable tells the electron command to use the build Electron instead of the build downloaded npm install

知否
221 声望177 粉丝

Skrike while the iron is hot.