执行参数


¥Execution arguments

execArgv 字段可用于指定 Node.js 特定的参数,这些参数将在单个可执行应用启动时自动应用。这允许应用开发者配置 Node.js 运行时选项,而无需终端用户注意这些标志。

¥The execArgv field can be used to specify Node.js-specific arguments that will be automatically applied when the single executable application starts. This allows application developers to configure Node.js runtime options without requiring end users to be aware of these flags.

例如,以下配置:

¥For example, the following configuration:

{
  "main": "/path/to/bundled/script.js",
  "output": "/path/to/write/the/generated/blob.blob",
  "execArgv": ["--no-warnings", "--max-old-space-size=2048"]
} 

将指示 SEA 使用 --no-warnings--max-old-space-size=2048 标志启动。在可执行文件中嵌入的脚本中,可以使用 process.execArgv 属性访问以下标志:

¥will instruct the SEA to be launched with the --no-warnings and --max-old-space-size=2048 flags. In the scripts embedded in the executable, these flags can be accessed using the process.execArgv property:

// If the executable is launched with `sea user-arg1 user-arg2`
console.log(process.execArgv);
// Prints: ['--no-warnings', '--max-old-space-size=2048']
console.log(process.argv);
// Prints ['/path/to/sea', 'path/to/sea', 'user-arg1', 'user-arg2'] 

用户提供的参数位于 process.argv 数组中,从索引 2 开始,类似于应用启动时的情况:

¥The user-provided arguments are in the process.argv array starting from index 2, similar to what would happen if the application is started with:

node --no-warnings --max-old-space-size=2048 /path/to/bundled/script.js user-arg1 user-arg2