执行参数扩展


¥Execution argument extension

execArgvExtension 字段控制如何提供除 execArgv 字段中指定的参数之外的其他执行参数。它接受以下三个字符串值之一:

¥The execArgvExtension field controls how additional execution arguments can be provided beyond those specified in the execArgv field. It accepts one of three string values:

  • "none":不允许扩展。仅使用 execArgv 中指定的参数,NODE_OPTIONS 环境变量将被忽略。

    ¥"none": No extension is allowed. Only the arguments specified in execArgv will be used, and the NODE_OPTIONS environment variable will be ignored.

  • "env":(默认)NODE_OPTIONS 环境变量可以扩展执行参数。这是保持向后兼容性的默认行为。

    ¥"env": (Default) The NODE_OPTIONS environment variable can extend the execution arguments. This is the default behavior to maintain backward compatibility.

  • "cli":可执行文件可以使用 --node-options="--flag1 --flag2" 启动,这些标志将被解析为 Node.js 的执行参数,而不是传递给用户脚本。这允许使用 NODE_OPTIONS 环境变量不支持的参数。

    ¥"cli": The executable can be launched with --node-options="--flag1 --flag2", and those flags will be parsed as execution arguments for Node.js instead of being passed to the user script. This allows using arguments that are not supported by the NODE_OPTIONS environment variable.

例如,对于 "execArgvExtension": "cli"

¥For example, with "execArgvExtension": "cli":

{
  "main": "/path/to/bundled/script.js",
  "output": "/path/to/write/the/generated/blob.blob",
  "execArgv": ["--no-warnings"],
  "execArgvExtension": "cli"
} 

可执行文件可以这样启动:

¥The executable can be launched as:

./my-sea --node-options="--trace-exit" user-arg1 user-arg2 

这相当于运行:

¥This would be equivalent to running:

node --no-warnings --trace-exit /path/to/bundled/script.js user-arg1 user-arg2