NODE_OPTIONS=options...
以空格分隔的命令行选项列表
options...
在命令行选项之前被解释,因此命令行选项将在 options...
中的任何内容之后覆盖或复合。如果使用了环境中不允许的选项,例如 -p
或脚本文件。
如果选项值包含空格,则可以使用双引号转义:
NODE_OPTIONS='--require "./my path/file.js"'
作为命令行选项传入的单例标志将覆盖传给 NODE_OPTIONS
的相同标志:
# 检查器将在端口 5555 上可用
NODE_OPTIONS='--inspect=localhost:4444' node --inspect=localhost:5555
可以多次传入的标志将被视为首先传入其 NODE_OPTIONS
实例,然后是其命令行实例:
NODE_OPTIONS='--require "./a.js"' node --require "./b.js"
# 相当于:
node --require "./a.js" --require "./b.js"
允许的 Node.js 选项是:
--conditions
、-C
--diagnostic-dir
--disable-proto
--dns-result-order
--enable-fips
--enable-source-maps
--experimental-abortcontroller
--experimental-fetch
--experimental-global-customevent
--experimental-global-webcrypto
--experimental-import-meta-resolve
--experimental-json-modules
--experimental-loader
--experimental-modules
--experimental-network-imports
--experimental-policy
--experimental-specifier-resolution
--experimental-top-level-await
--experimental-vm-modules
--experimental-wasi-unstable-preview1
--experimental-wasm-modules
--force-context-aware
--force-fips
--force-node-api-uncaught-exceptions-policy
--frozen-intrinsics
--heapsnapshot-near-heap-limit
--heapsnapshot-signal
--http-parser
--icu-data-dir
--input-type
--insecure-http-parser
--inspect-brk
--inspect-port
、--debug-port
--inspect-publish-uid
--inspect
--max-http-header-size
--napi-modules
--no-addons
--no-deprecation
--no-experimental-repl-await
--no-force-async-hooks-checks
--no-global-search-paths
--no-warnings
--node-memory-debug
--openssl-config
--openssl-legacy-provider
--openssl-shared-config
--pending-deprecation
--policy-integrity
--preserve-symlinks-main
--preserve-symlinks
--prof-process
--redirect-warnings
--report-compact
--report-dir
、--report-directory
--report-filename
--report-on-fatalerror
--report-on-signal
--report-signal
--report-uncaught-exception
--require
、-r
--secure-heap-min
--secure-heap
--test-only
--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-event-categories
--trace-event-file-pattern
--trace-events-enabled
--trace-exit
--trace-sigint
--trace-sync-io
--trace-tls
--trace-uncaught
--trace-warnings
--track-heap-objects
--unhandled-rejections
--use-bundled-ca
--use-largepages
--use-openssl-ca
--v8-pool-size
--watch-path
--watch
--zero-fill-buffers
允许的 V8 选项是:
--abort-on-uncaught-exception
--disallow-code-generation-from-strings
--huge-max-old-generation-size
--interpreted-frames-native-stack
--jitless
--max-old-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 上可用。
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"'
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
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 options that are allowed are:
--conditions
,-C
--diagnostic-dir
--disable-proto
--dns-result-order
--enable-fips
--enable-source-maps
--experimental-abortcontroller
--experimental-fetch
--experimental-global-customevent
--experimental-global-webcrypto
--experimental-import-meta-resolve
--experimental-json-modules
--experimental-loader
--experimental-modules
--experimental-network-imports
--experimental-policy
--experimental-specifier-resolution
--experimental-top-level-await
--experimental-vm-modules
--experimental-wasi-unstable-preview1
--experimental-wasm-modules
--force-context-aware
--force-fips
--force-node-api-uncaught-exceptions-policy
--frozen-intrinsics
--heapsnapshot-near-heap-limit
--heapsnapshot-signal
--http-parser
--icu-data-dir
--input-type
--insecure-http-parser
--inspect-brk
--inspect-port
,--debug-port
--inspect-publish-uid
--inspect
--max-http-header-size
--napi-modules
--no-addons
--no-deprecation
--no-experimental-repl-await
--no-force-async-hooks-checks
--no-global-search-paths
--no-warnings
--node-memory-debug
--openssl-config
--openssl-legacy-provider
--openssl-shared-config
--pending-deprecation
--policy-integrity
--preserve-symlinks-main
--preserve-symlinks
--prof-process
--redirect-warnings
--report-compact
--report-dir
,--report-directory
--report-filename
--report-on-fatalerror
--report-on-signal
--report-signal
--report-uncaught-exception
--require
,-r
--secure-heap-min
--secure-heap
--test-only
--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-event-categories
--trace-event-file-pattern
--trace-events-enabled
--trace-exit
--trace-sigint
--trace-sync-io
--trace-tls
--trace-uncaught
--trace-warnings
--track-heap-objects
--unhandled-rejections
--use-bundled-ca
--use-largepages
--use-openssl-ca
--v8-pool-size
--watch-path
--watch
--zero-fill-buffers
V8 options that are allowed are:
--abort-on-uncaught-exception
--disallow-code-generation-from-strings
--huge-max-old-generation-size
--interpreted-frames-native-stack
--jitless
--max-old-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
, and --perf-prof
are only available on Linux.