Skip to content

Baked CLI options

Node.js applications can be launched with runtime options belonging to Node.js or V8 — --max-old-space-size, --expose-gc, --tls-min-v1.0, and friends. To list the full set, run node --help or node --v8-options.

You can bake these runtime options into the packaged executable. The app will always run with the options turned on, even when the end user launches it without any flags. Just drop the leading -- from each option name.

Syntax

Join multiple options with commas, no spaces:

sh
pkg app.js --options expose-gc
pkg app.js --options max_old_space_size=4096
pkg app.js --options max-old-space-size=1024,tls-min-v1.0,expose-gc

Or set pkg.options in package.json:

json
{
  "pkg": {
    "options": "max-old-space-size=2048,expose-gc"
  }
}

Common use cases

OptionWhy bake it
max-old-space-size=NRaise the V8 heap ceiling for memory-heavy CLI tools
expose-gcLet the app call global.gc() for manual collection
tls-min-v1.0Accept legacy TLS — interop with old internal services
unhandled-rejections=strictTurn unhandled promise rejections into hard crashes
enable-source-mapsProduce meaningful stack traces in production

Pass-through vs baked

Baked options always apply. End users can't turn them off. If you want users to override, don't bake — document the flag in your --help and let them pass it.

See also

Released under the MIT License.