Перейти к основному содержанию

Поддерживаемые параметры командной строки

Параметры командной строки поддерживаемые Electron.

You can use app.commandLine.appendSwitch to append them in your app's main script before the ready event of the app module is emitted:

const { app } = require('electron')

app.commandLine.appendSwitch('remote-debugging-port', '8315')
app.commandLine.appendSwitch('host-rules', 'MAP * 127.0.0.1')

app.whenReady().then(() => {
// Your code here
})

Electron CLI Flags

--auth-server-whitelist=ссылка

Список серверов (разделенные запятой), для которых разрешена интегрированная аутентификация.

Например:

--auth-server-whitelist='*example.com, *foobar.com, *baz'

тогда любая ссылка заканчивающаяся на example.com, foobar.com и baz будут рассматриваться для интегрированной аутентификации. Без префикса *, ссылка будет полностью соответствовать.

--auth-negotiate-delegate-whitelist=ссылка

A comma-separated list of servers for which delegation of user credentials is required. Без префикса *, ссылка будет полностью соответствовать.

--disable-ntlm-v2

Disables NTLM v2 for POSIX platforms, no effect elsewhere.

--disable-http-cache

Отключить кэширование на жёсткий диск для HTTP запросов.

--disable-http2

Отключить HTTP/2 и SPDY/3.1 протоколы.

--disable-geolocation macOS

Disables the Geolocation API. Permission requests for geolocation will be denied internally regardless of the decision made by a handler set via session.setPermissionRequestHandler. This functionality is currently implemented only for macOS. Has no effect on other platforms.

--disable-renderer-backgrounding

Предотвращает Chromium от понижения приоритета для невидимых страниц графических процессов.

Этот параметр глобален для всех графических процессов, если Вы хотите отключить троттлинг в одном окне, Вы может использовать трюк с проигрыванием беззвучных звуков.

--disk-cache-size=размер

Максимальный размер кеша на жёстком диске в байтах.

--enable-logging[=file]

Prints Chromium's logging to stderr (or a log file).

The ELECTRON_ENABLE_LOGGING environment variable has the same effect as passing --enable-logging.

Passing --enable-logging will result in logs being printed on stderr. Passing --enable-logging=file will result in logs being saved to the file specified by --log-file=..., or to electron_debug.log in the user-data directory if --log-file is not specified.

[!NOTE] On Windows, logs from child processes cannot be sent to stderr. Logging to a file is the most reliable way to collect logs on Windows.

See also --log-file, --log-level, --v, and --vmodule.

--force-fieldtrials=trials

Field trials to be forcefully enabled or disabled.

For example: WebRTC-Audio-Red-For-Opus/Enabled/

--host-rules=rules Deprecated

Список правил, разделённых точкой с запятой, которые контролируют как сопоставляются имена хостов.

Например:

  • MAP * 127.0.0.1 Все имена хостов будут перенаправлены на 127.0.0.1
  • MAP *.google.com proxy Заставляет все поддомены google.com обращаться к "proxy".
  • MAP test.com [::1]:77 Forces "test.com" to resolve to IPv6 loopback. Также принудительно выставит порт получаемого адреса сокета, равный 77.
  • MAP * baz, EXCLUDE www.google.com Перенаправляет всё на "baz", за исключением "www.google.com".

Эти перенаправления применяются к хосту конечной точки в сетевом запросе (TCP соединения и резолвер хоста в прямых соединениях, CONNECT в HTTP прокси-соединениях и хост конечной точки в SOCKS прокси-соединений).

Deprecated: Use the --host-resolver-rules switch instead.

--host-resolver-rules=правила

Список правил, разделённых точкой с запятой, которые контролируют как сопоставляются имена хостов.

Например:

  • MAP * 127.0.0.1 Все имена хостов будут перенаправлены на 127.0.0.1
  • MAP *.google.com proxy Заставляет все поддомены google.com обращаться к "proxy".
  • MAP test.com [::1]:77 Forces "test.com" to resolve to IPv6 loopback. Также принудительно выставит порт получаемого адреса сокета, равный 77.
  • MAP * baz, EXCLUDE www.google.com Перенаправляет всё на "baz", за исключением "www.google.com".

These rules only apply to the host resolver.

--ignore-certificate-errors

Игнорирует ошибки, связанные с сертификатами.

--ignore-connections-limit=домены

Игнорировать лимит подключения для списка доменов, разделённых ,.

--js-flags=флаги

Specifies the flags passed to the V8 engine. In order to enable the flags in the main process, this switch must be passed on startup.

$ electron --js-flags="--harmony_proxies --harmony_collections" your-app

Run node --v8-options or electron --js-flags="--help" in your terminal for the list of available flags. These can be used to enable early-stage JavaScript features, or log and manipulate garbage collection, among other things.

For example, to trace V8 optimization and deoptimization:

$ electron --js-flags="--trace-opt --trace-deopt" your-app

--lang

Установить пользовательский язык.

--log-file=path

If --enable-logging is specified, logs will be written to the given path. The parent directory must exist.

Setting the ELECTRON_LOG_FILE environment variable is equivalent to passing this flag. If both are present, the command-line switch takes precedence.

--log-net-log=путь

Включает логи сетевых событий для сохранения и записывает их в путь.

--log-level=N

Sets the verbosity of logging when used together with --enable-logging. N should be one of Chrome's LogSeverities.

Note that two complementary logging mechanisms in Chromium -- LOG() and VLOG() -- are controlled by different switches. --log-level controls LOG() messages, while --v and --vmodule control VLOG() messages. So you may want to use a combination of these three switches depending on the granularity you want and what logging calls are made by the code you're trying to watch.

See Chromium Logging source for more information on how LOG() and VLOG() interact. Loosely speaking, VLOG() can be thought of as sub-levels / per-module levels inside LOG(INFO) to control the firehose of LOG(INFO) data.

See also --enable-logging, --log-level, --v, and --vmodule.

--no-proxy-server

Не использовать прокси сервер и всегда делать прямые соединения. Переопределяет все остальные флаги прокси-сервера, которые были указаны.

--no-sandbox

Disables the Chromium sandbox. Forces renderer process and Chromium helper processes to run un-sandboxed. Should only be used for testing.

--no-stdio-init

Disable stdio initialization during node initialization. Used to avoid node initialization crash when the nul device is disabled on Windows platform.

--proxy-bypass-list=хосты

Указывает Electron обходить прокси-сервер для списка хостов, разделённых точкой с запятой. Этот флаг действует только в том случае, если он используется вместе с --proxy-server.

Например:

const { app } = require('electron')

app.commandLine.appendSwitch('proxy-bypass-list', '<local>;*.google.com;*foo.com;1.2.3.4:5678')

Будет использовать прокси сервер для всех хостов, за исключением локальных адресов (localhost, 127.0.0.1 и т. д.), google.com поддоменов, хостов которые содержат foo.com и 1.2.3.4:5678.

--proxy-pac-url=ссылка

Использовать PAC скрипт для указанного url.

--proxy-server=адрес:порт

Использует указанный proxy сервер, который перезаписывает системные настройки. Этот параметр влияет только на запросы HTTP протокола, включая HTTPS и WebSocket. Примечательно также, что не все proxy серверы поддерживают HTTPS и WebSocket протоколы. В URL для прокси не поддерживается указание имени пользователя и пароля для аутентификации, из-за проблемы в Chromium.

--remote-debugging-port=порт

Включает удалённую отладку через HTTP для указанного порта.

--v=уровень_логирования

Gives the default maximal active V-logging level; 0 is the default. Normally positive values are used for V-logging levels.

Этот параметр работает только когда --enable-logging также указан.

See also --enable-logging, --log-level, and --vmodule.

--vmodule=шаблон

Дает на каждый модуль максимальный уровень V-логирования, чтобы переопределить значения, заданное --v. Например, my_module=2,foo*=3 would change the logging level for all code in source files my_module.* and foo*.*.

Любой шаблон, содержащий переднюю или обратную косую черту, будет протестирован против всего пути, а не только модуля. Например, */foo/bar/*=2 would change the logging level for all code in the source files under a foo/bar directory.

Этот параметр работает только когда --enable-logging также указан.

See also --enable-logging, --log-level, and --v.

--force_high_performance_gpu

Force using discrete GPU when there are multiple GPUs available.

--force_low_power_gpu

Force using integrated GPU when there are multiple GPUs available.

--xdg-portal-required-version=version

Sets the minimum required version of XDG portal implementation to version in order to use the portal backend for file dialogs on linux. File dialogs will fallback to using gtk or kde depending on the desktop environment when the required version is unavailable. Current default is set to 3.

Node.js Flags

Electron поддерживает некоторые из флагов CLI, поддерживаемых Node.js.

[!NOTE] Passing unsupported command line switches to Electron when it is not running in ELECTRON_RUN_AS_NODE will have no effect.