NODE_OPTIONS=options...
以空格分隔的命令行选项列表options... 在命令行选项之前被解释,因此命令行选项将覆盖或复合在 options... 中的任何内容之后。如果使用环境中不允许的选项(例如 -p 或脚本文件),Node.js 将退出并出错。
¥A space-separated list of command-line options. options... are interpreted
before command-line options, so command-line options will override or
compound after anything in options.... Node.js will exit with an error if
an option that is not allowed in the environment is used, such as -p or a
script file.
如果选项值包含空格,则可以使用双引号转义:
¥If an option value contains a space, it can be escaped using double quotes:
NODE_OPTIONS='--require "./my path/file.js"' 作为命令行选项传入的单例标志将覆盖传给 NODE_OPTIONS 的相同标志:
¥A singleton flag passed as a command-line option will override the same flag
passed into NODE_OPTIONS:
# The inspector will be available on port 5555
NODE_OPTIONS='--inspect=localhost:4444' node --inspect=localhost:5555 可以多次传入的标志将被视为首先传入其 NODE_OPTIONS 实例,然后是其命令行实例:
¥A flag that can be passed multiple times will be treated as if its
NODE_OPTIONS instances were passed first, and then its command-line
instances afterwards:
NODE_OPTIONS='--require "./a.js"' node --require "./b.js"
# is equivalent to:
node --require "./a.js" --require "./b.js" 允许的 Node.js 选项位于以下列表中。如果一个选项同时支持 --XX 和 --no-XX 变体,则它们都受支持,但下面的列表中仅包含一个。
¥Node.js options that are allowed are in the following list. If an option supports both --XX and --no-XX variants, they are both supported but only one is included in the list below.
- 
--allow-addons - 
--allow-child-process - 
--allow-fs-read - 
--allow-fs-write - 
--allow-wasi - 
--allow-worker - 
--conditions,-C - 
--cpu-prof-dir - 
--cpu-prof-interval - 
--cpu-prof-name - 
--cpu-prof - 
--diagnostic-dir - 
--disable-proto - 
--disable-sigusr1 - 
--disable-warning - 
--disable-wasm-trap-handler - 
--dns-result-order - 
--enable-fips - 
--enable-network-family-autoselection - 
--enable-source-maps - 
--entry-url - 
--experimental-abortcontroller - 
--experimental-addon-modules - 
--experimental-async-context-frame - 
--experimental-default-type - 
--experimental-detect-module - 
--experimental-eventsource - 
--experimental-import-meta-resolve - 
--experimental-json-modules - 
--experimental-loader - 
--experimental-modules - 
--experimental-permission - 
--experimental-print-required-tla - 
--experimental-require-module - 
--experimental-shadow-realm - 
--experimental-specifier-resolution - 
--experimental-top-level-await - 
--experimental-transform-types - 
--experimental-vm-modules - 
--experimental-wasi-unstable-preview1 - 
--experimental-webstorage - 
--force-context-aware - 
--force-fips - 
--force-node-api-uncaught-exceptions-policy - 
--frozen-intrinsics - 
--heap-prof-dir - 
--heap-prof-interval - 
--heap-prof-name - 
--heap-prof - 
--heapsnapshot-near-heap-limit - 
--heapsnapshot-signal - 
--http-parser - 
--icu-data-dir - 
--import - 
--input-type - 
--insecure-http-parser - 
--inspect-brk - 
--inspect-port,--debug-port - 
--inspect-publish-uid - 
--inspect-wait - 
--inspect - 
--localstorage-file - 
--max-http-header-size - 
--max-old-space-size-percentage - 
--napi-modules - 
--network-family-autoselection-attempt-timeout - 
--no-addons - 
--no-deprecation - 
--no-experimental-fetch - 
--no-experimental-global-customevent - 
--no-experimental-global-navigator - 
--no-experimental-global-webcrypto - 
--no-experimental-repl-await - 
--no-experimental-sqlite - 
--no-experimental-strip-types - 
--no-experimental-websocket - 
--no-extra-info-on-fatal-exception - 
--no-force-async-hooks-checks - 
--no-global-search-paths - 
--no-network-family-autoselection - 
--no-warnings - 
--node-memory-debug - 
--openssl-config - 
--openssl-legacy-provider - 
--openssl-shared-config - 
--pending-deprecation - 
--permission - 
--preserve-symlinks-main - 
--preserve-symlinks - 
--prof-process - 
--redirect-warnings - 
--report-compact - 
--report-dir,--report-directory - 
--report-exclude-env - 
--report-exclude-network - 
--report-filename - 
--report-on-fatalerror - 
--report-on-signal - 
--report-signal - 
--report-uncaught-exception - 
--require,-r - 
--secure-heap-min - 
--secure-heap - 
--snapshot-blob - 
--test-coverage-branches - 
--test-coverage-exclude - 
--test-coverage-functions - 
--test-coverage-include - 
--test-coverage-lines - 
--test-name-pattern - 
--test-only - 
--test-reporter-destination - 
--test-reporter - 
--test-shard - 
--test-skip-pattern - 
--throw-deprecation - 
--title - 
--tls-cipher-list - 
--tls-keylog - 
--tls-max-v1.2 - 
--tls-max-v1.3 - 
--tls-min-v1.0 - 
--tls-min-v1.1 - 
--tls-min-v1.2 - 
--tls-min-v1.3 - 
--trace-atomics-wait - 
--trace-deprecation - 
--trace-env-js-stack - 
--trace-env-native-stack - 
--trace-env - 
--trace-event-categories - 
--trace-event-file-pattern - 
--trace-events-enabled - 
--trace-exit - 
--trace-require-module - 
--trace-sigint - 
--trace-sync-io - 
--trace-tls - 
--trace-uncaught - 
--trace-warnings - 
--track-heap-objects - 
--unhandled-rejections - 
--use-bundled-ca - 
--use-env-proxy - 
--use-largepages - 
--use-openssl-ca - 
--use-system-ca - 
--v8-pool-size - 
--watch-kill-signal - 
--watch-path - 
--watch-preserve-output - 
--watch - 
--zero-fill-buffers 
允许的 V8 选项是:
¥V8 options that are allowed are:
- 
--abort-on-uncaught-exception - 
--disallow-code-generation-from-strings - 
--enable-etw-stack-walking - 
--expose-gc - 
--huge-max-old-generation-size - 
--interpreted-frames-native-stack - 
--jitless - 
--max-old-space-size - 
--max-semi-space-size - 
--perf-basic-prof-only-functions - 
--perf-basic-prof - 
--perf-prof-unwinding-info - 
--perf-prof - 
--stack-trace-limit 
--perf-basic-prof-only-functions、--perf-basic-prof、--perf-prof-unwinding-info 和 --perf-prof 仅在 Linux 上可用。
¥--perf-basic-prof-only-functions, --perf-basic-prof,
--perf-prof-unwinding-info, and --perf-prof are only available on Linux.
--enable-etw-stack-walking 仅适用于 Windows。
¥--enable-etw-stack-walking is only available on Windows.