1# Command line options 2 3<!--introduced_in=v5.9.1--> 4<!--type=misc--> 5 6Node.js comes with a variety of CLI options. These options expose built-in 7debugging, multiple ways to execute scripts, and other helpful runtime options. 8 9To view this documentation as a manual page in a terminal, run `man node`. 10 11## Synopsis 12 13`node [options] [V8 options] [script.js | -e "script" | -] [--] [arguments]` 14 15`node inspect [script.js | -e "script" | <host>:<port>] …` 16 17`node --v8-options` 18 19Execute without arguments to start the [REPL][]. 20 21_For more info about `node inspect`, please see the [debugger][] documentation._ 22 23## Options 24<!-- YAML 25changes: 26 - version: v10.12.0 27 pr-url: https://github.com/nodejs/node/pull/23020 28 description: Underscores instead of dashes are now allowed for 29 Node.js options as well, in addition to V8 options. 30--> 31 32All options, including V8 options, allow words to be separated by both 33dashes (`-`) or underscores (`_`). 34 35For example, `--pending-deprecation` is equivalent to `--pending_deprecation`. 36 37If an option that takes a single value, for example `--max-http-header-size`, 38is passed more than once, then the last passed value will be used. Options 39from the command line take precedence over options passed through the 40[`NODE_OPTIONS`][] environment variable. 41 42### `-` 43<!-- YAML 44added: v8.0.0 45--> 46 47Alias for stdin. Analogous to the use of `-` in other command line utilities, 48meaning that the script will be read from stdin, and the rest of the options 49are passed to that script. 50 51### `--` 52<!-- YAML 53added: v6.11.0 54--> 55 56Indicate the end of node options. Pass the rest of the arguments to the script. 57If no script filename or eval/print script is supplied prior to this, then 58the next argument will be used as a script filename. 59 60### `--abort-on-uncaught-exception` 61<!-- YAML 62added: v0.10.8 63--> 64 65Aborting instead of exiting causes a core file to be generated for post-mortem 66analysis using a debugger (such as `lldb`, `gdb`, and `mdb`). 67 68If this flag is passed, the behavior can still be set to not abort through 69[`process.setUncaughtExceptionCaptureCallback()`][] (and through usage of the 70`domain` module that uses it). 71 72### `--completion-bash` 73<!-- YAML 74added: v10.12.0 75--> 76 77Print source-able bash completion script for Node.js. 78 79```console 80$ node --completion-bash > node_bash_completion 81$ source node_bash_completion 82``` 83 84### `--conditions=condition` 85<!-- YAML 86added: v12.19.0 87--> 88 89> Stability: 1 - Experimental 90 91Enable experimental support for custom conditional exports resolution 92conditions. 93 94Any number of custom string condition names are permitted. 95 96The default Node.js conditions of `"node"`, `"default"`, `"import"`, and 97`"require"` will always apply as defined. 98 99### `--cpu-prof` 100<!-- YAML 101added: v12.0.0 102--> 103 104> Stability: 1 - Experimental 105 106Starts the V8 CPU profiler on start up, and writes the CPU profile to disk 107before exit. 108 109If `--cpu-prof-dir` is not specified, the generated profile will be placed 110in the current working directory. 111 112If `--cpu-prof-name` is not specified, the generated profile will be 113named `CPU.${yyyymmdd}.${hhmmss}.${pid}.${tid}.${seq}.cpuprofile`. 114 115```console 116$ node --cpu-prof index.js 117$ ls *.cpuprofile 118CPU.20190409.202950.15293.0.0.cpuprofile 119``` 120 121### `--cpu-prof-dir` 122<!-- YAML 123added: v12.0.0 124--> 125 126> Stability: 1 - Experimental 127 128Specify the directory where the CPU profiles generated by `--cpu-prof` will 129be placed. 130 131The default value is controlled by the 132[--diagnostic-dir](#cli_diagnostic_dir_directory) command line option. 133 134### `--cpu-prof-interval` 135<!-- YAML 136added: v12.2.0 137--> 138 139> Stability: 1 - Experimental 140 141Specify the sampling interval in microseconds for the CPU profiles generated 142by `--cpu-prof`. The default is 1000 microseconds. 143 144### `--cpu-prof-name` 145<!-- YAML 146added: v12.0.0 147--> 148 149> Stability: 1 - Experimental 150 151Specify the file name of the CPU profile generated by `--cpu-prof`. 152 153### `--diagnostic-dir=directory` 154 155Set the directory to which all diagnostic output files will be written to. 156Defaults to current working directory. 157 158Affects the default output directory of: 159* [--cpu-prof-dir](#cli_cpu_prof_dir) 160* [--heap-prof-dir](#cli_heap_prof_dir) 161* [--redirect-warnings](#cli_redirect_warnings_file) 162 163### `--disable-proto=mode` 164<!--YAML 165added: v12.17.0 166--> 167 168Disable the `Object.prototype.__proto__` property. If `mode` is `delete`, the 169property will be removed entirely. If `mode` is `throw`, accesses to the 170property will throw an exception with the code `ERR_PROTO_ACCESS`. 171 172### `--disallow-code-generation-from-strings` 173<!-- YAML 174added: v9.8.0 175--> 176 177Make built-in language features like `eval` and `new Function` that generate 178code from strings throw an exception instead. This does not affect the Node.js 179`vm` module. 180 181### `--enable-fips` 182<!-- YAML 183added: v6.0.0 184--> 185 186Enable FIPS-compliant crypto at startup. (Requires Node.js to be built with 187`./configure --openssl-fips`.) 188 189### `--enable-source-maps` 190<!-- YAML 191added: v12.12.0 192--> 193 194> Stability: 1 - Experimental 195 196Enable experimental Source Map v3 support for stack traces. 197 198Currently, overriding `Error.prepareStackTrace` is ignored when the 199`--enable-source-maps` flag is set. 200 201### `--experimental-import-meta-resolve` 202<!-- YAML 203added: v12.16.2 204--> 205 206Enable experimental `import.meta.resolve()` support. 207 208### `--experimental-json-modules` 209<!-- YAML 210added: v12.9.0 211--> 212 213Enable experimental JSON support for the ES Module loader. 214 215### `--experimental-loader=module` 216<!-- YAML 217added: v9.0.0 218--> 219 220Specify the `module` of a custom [experimental ECMAScript Module loader][]. 221`module` may be either a path to a file, or an ECMAScript Module name. 222 223### `--experimental-modules` 224<!-- YAML 225added: v8.5.0 226--> 227 228Enable latest experimental modules features (deprecated). 229 230### `--experimental-policy` 231<!-- YAML 232added: v11.8.0 233--> 234 235Use the specified file as a security policy. 236 237### `--experimental-repl-await` 238<!-- YAML 239added: v10.0.0 240--> 241 242Enable experimental top-level `await` keyword support in REPL. 243 244### `--experimental-specifier-resolution=mode` 245<!-- YAML 246added: v12.16.0 247--> 248 249Sets the resolution algorithm for resolving ES module specifiers. Valid options 250are `explicit` and `node`. 251 252The default is `explicit`, which requires providing the full path to a 253module. The `node` mode will enable support for optional file extensions and 254the ability to import a directory that has an index file. 255 256Please see [customizing ESM specifier resolution][] for example usage. 257 258### `--experimental-vm-modules` 259<!-- YAML 260added: v9.6.0 261--> 262 263Enable experimental ES Module support in the `vm` module. 264 265### `--experimental-wasi-unstable-preview1` 266<!-- YAML 267added: v12.16.0 268--> 269 270Enable experimental WebAssembly System Interface (WASI) support. 271 272### `--experimental-wasm-modules` 273<!-- YAML 274added: v12.3.0 275--> 276 277### `--force-context-aware` 278<!-- YAML 279added: v12.12.0 280--> 281 282Disable loading native addons that are not [context-aware][]. 283 284Enable experimental WebAssembly module support. 285 286### `--force-fips` 287<!-- YAML 288added: v6.0.0 289--> 290 291Force FIPS-compliant crypto on startup. (Cannot be disabled from script code.) 292(Same requirements as `--enable-fips`.) 293 294### `--frozen-intrinsics` 295<!-- YAML 296added: v11.12.0 297--> 298 299> Stability: 1 - Experimental 300 301Enable experimental frozen intrinsics like `Array` and `Object`. 302 303Support is currently only provided for the root context and no guarantees are 304currently provided that `global.Array` is indeed the default intrinsic 305reference. Code may break under this flag. 306 307`--require` runs prior to freezing intrinsics in order to allow polyfills to 308be added. 309 310### `--heapsnapshot-signal=signal` 311<!-- YAML 312added: v12.0.0 313--> 314 315Enables a signal handler that causes the Node.js process to write a heap dump 316when the specified signal is received. `signal` must be a valid signal name. 317Disabled by default. 318 319```console 320$ node --heapsnapshot-signal=SIGUSR2 index.js & 321$ ps aux 322USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND 323node 1 5.5 6.1 787252 247004 ? Ssl 16:43 0:02 node --heapsnapshot-signal=SIGUSR2 index.js 324$ kill -USR2 1 325$ ls 326Heap.20190718.133405.15554.0.001.heapsnapshot 327``` 328 329### `--heap-prof` 330<!-- YAML 331added: v12.4.0 332--> 333 334> Stability: 1 - Experimental 335 336Starts the V8 heap profiler on start up, and writes the heap profile to disk 337before exit. 338 339If `--heap-prof-dir` is not specified, the generated profile will be placed 340in the current working directory. 341 342If `--heap-prof-name` is not specified, the generated profile will be 343named `Heap.${yyyymmdd}.${hhmmss}.${pid}.${tid}.${seq}.heapprofile`. 344 345```console 346$ node --heap-prof index.js 347$ ls *.heapprofile 348Heap.20190409.202950.15293.0.001.heapprofile 349``` 350 351### `--heap-prof-dir` 352<!-- YAML 353added: v12.4.0 354--> 355 356> Stability: 1 - Experimental 357 358Specify the directory where the heap profiles generated by `--heap-prof` will 359be placed. 360 361The default value is controlled by the 362[--diagnostic-dir](#cli_diagnostic_dir_directory) command line option. 363 364### `--heap-prof-interval` 365<!-- YAML 366added: v12.4.0 367--> 368 369> Stability: 1 - Experimental 370 371Specify the average sampling interval in bytes for the heap profiles generated 372by `--heap-prof`. The default is 512 * 1024 bytes. 373 374### `--heap-prof-name` 375<!-- YAML 376added: v12.4.0 377--> 378 379> Stability: 1 - Experimental 380 381Specify the file name of the heap profile generated by `--heap-prof`. 382 383### `--http-parser=library` 384<!-- YAML 385added: v11.4.0 386--> 387 388Chooses an HTTP parser library. Available values are: 389 390* `llhttp` for <https://llhttp.org/> 391* `legacy` for <https://github.com/nodejs/http-parser> 392 393The default is `llhttp`, unless otherwise specified when building Node.js. 394 395This flag exists to aid in experimentation with the internal implementation of 396the Node.js http parser. 397This flag is likely to become a no-op and removed at some point in the future. 398 399### `--http-server-default-timeout=milliseconds` 400<!-- YAML 401added: v12.4.0 402--> 403 404Overrides the default value of `http`, `https` and `http2` server socket 405timeout. Setting the value to 0 disables server socket timeout. Unless 406provided, http server sockets timeout after 120s (2 minutes). Programmatic 407setting of the timeout takes precedence over the value set through this 408flag. 409 410### `--icu-data-dir=file` 411<!-- YAML 412added: v0.11.15 413--> 414 415Specify ICU data load path. (Overrides `NODE_ICU_DATA`.) 416 417### `--input-type=type` 418<!-- YAML 419added: v12.0.0 420--> 421 422This configures Node.js to interpret string input as CommonJS or as an ES 423module. String input is input via `--eval`, `--print`, or `STDIN`. 424 425Valid values are `"commonjs"` and `"module"`. The default is `"commonjs"`. 426 427### `--inspect-brk[=[host:]port]` 428<!-- YAML 429added: v7.6.0 430--> 431 432Activate inspector on `host:port` and break at start of user script. 433Default `host:port` is `127.0.0.1:9229`. 434 435### `--inspect-port=[host:]port` 436<!-- YAML 437added: v7.6.0 438--> 439 440Set the `host:port` to be used when the inspector is activated. 441Useful when activating the inspector by sending the `SIGUSR1` signal. 442 443Default host is `127.0.0.1`. 444 445See the [security warning](#inspector_security) below regarding the `host` 446parameter usage. 447 448### `--inspect[=[host:]port]` 449<!-- YAML 450added: v6.3.0 451--> 452 453Activate inspector on `host:port`. Default is `127.0.0.1:9229`. 454 455V8 inspector integration allows tools such as Chrome DevTools and IDEs to debug 456and profile Node.js instances. The tools attach to Node.js instances via a 457tcp port and communicate using the [Chrome DevTools Protocol][]. 458 459<a id="inspector_security"></a> 460#### Warning: binding inspector to a public IP:port combination is insecure 461 462Binding the inspector to a public IP (including `0.0.0.0`) with an open port is 463insecure, as it allows external hosts to connect to the inspector and perform 464a [remote code execution][] attack. 465 466If specifying a host, make sure that either: 467 468* The host is not accessible from public networks. 469* A firewall disallows unwanted connections on the port. 470 471**More specifically, `--inspect=0.0.0.0` is insecure if the port (`9229` by 472default) is not firewall-protected.** 473 474See the [debugging security implications][] section for more information. 475 476### `--inspect-publish-uid=stderr,http` 477 478Specify ways of the inspector web socket url exposure. 479 480By default inspector websocket url is available in stderr and under `/json/list` 481endpoint on `http://host:port/json/list`. 482 483### `--insecure-http-parser` 484<!-- YAML 485added: v12.15.0 486--> 487 488Use an insecure HTTP parser that accepts invalid HTTP headers. This may allow 489interoperability with non-conformant HTTP implementations. It may also allow 490request smuggling and other HTTP attacks that rely on invalid headers being 491accepted. Avoid using this option. 492 493### `--jitless` 494<!-- YAML 495added: v12.0.0 496--> 497 498Disable [runtime allocation of executable memory][jitless]. This may be 499required on some platforms for security reasons. It can also reduce attack 500surface on other platforms, but the performance impact may be severe. 501 502This flag is inherited from V8 and is subject to change upstream. It may 503disappear in a non-semver-major release. 504 505### `--max-http-header-size=size` 506<!-- YAML 507added: v11.6.0 508--> 509 510Specify the maximum size, in bytes, of HTTP headers. Defaults to 8KB. 511 512### `--napi-modules` 513<!-- YAML 514added: v7.10.0 515--> 516 517This option is a no-op. It is kept for compatibility. 518 519### `--no-deprecation` 520<!-- YAML 521added: v0.8.0 522--> 523 524Silence deprecation warnings. 525 526### `--no-force-async-hooks-checks` 527<!-- YAML 528added: v9.0.0 529--> 530 531Disables runtime checks for `async_hooks`. These will still be enabled 532dynamically when `async_hooks` is enabled. 533 534### `--no-warnings` 535<!-- YAML 536added: v6.0.0 537--> 538 539Silence all process warnings (including deprecations). 540 541### `--openssl-config=file` 542<!-- YAML 543added: v6.9.0 544--> 545 546Load an OpenSSL configuration file on startup. Among other uses, this can be 547used to enable FIPS-compliant crypto if Node.js is built with 548`./configure --openssl-fips`. 549 550### `--pending-deprecation` 551<!-- YAML 552added: v8.0.0 553--> 554 555Emit pending deprecation warnings. 556 557Pending deprecations are generally identical to a runtime deprecation with the 558notable exception that they are turned *off* by default and will not be emitted 559unless either the `--pending-deprecation` command line flag, or the 560`NODE_PENDING_DEPRECATION=1` environment variable, is set. Pending deprecations 561are used to provide a kind of selective "early warning" mechanism that 562developers may leverage to detect deprecated API usage. 563 564### `--policy-integrity=sri` 565<!-- YAML 566added: v12.7.0 567--> 568 569> Stability: 1 - Experimental 570 571Instructs Node.js to error prior to running any code if the policy does not have 572the specified integrity. It expects a [Subresource Integrity][] string as a 573parameter. 574 575### `--preserve-symlinks` 576<!-- YAML 577added: v6.3.0 578--> 579 580Instructs the module loader to preserve symbolic links when resolving and 581caching modules. 582 583By default, when Node.js loads a module from a path that is symbolically linked 584to a different on-disk location, Node.js will dereference the link and use the 585actual on-disk "real path" of the module as both an identifier and as a root 586path to locate other dependency modules. In most cases, this default behavior 587is acceptable. However, when using symbolically linked peer dependencies, as 588illustrated in the example below, the default behavior causes an exception to 589be thrown if `moduleA` attempts to require `moduleB` as a peer dependency: 590 591```text 592{appDir} 593 ├── app 594 │ ├── index.js 595 │ └── node_modules 596 │ ├── moduleA -> {appDir}/moduleA 597 │ └── moduleB 598 │ ├── index.js 599 │ └── package.json 600 └── moduleA 601 ├── index.js 602 └── package.json 603``` 604 605The `--preserve-symlinks` command line flag instructs Node.js to use the 606symlink path for modules as opposed to the real path, allowing symbolically 607linked peer dependencies to be found. 608 609Note, however, that using `--preserve-symlinks` can have other side effects. 610Specifically, symbolically linked *native* modules can fail to load if those 611are linked from more than one location in the dependency tree (Node.js would 612see those as two separate modules and would attempt to load the module multiple 613times, causing an exception to be thrown). 614 615The `--preserve-symlinks` flag does not apply to the main module, which allows 616`node --preserve-symlinks node_module/.bin/<foo>` to work. To apply the same 617behavior for the main module, also use `--preserve-symlinks-main`. 618 619### `--preserve-symlinks-main` 620<!-- YAML 621added: v10.2.0 622--> 623 624Instructs the module loader to preserve symbolic links when resolving and 625caching the main module (`require.main`). 626 627This flag exists so that the main module can be opted-in to the same behavior 628that `--preserve-symlinks` gives to all other imports; they are separate flags, 629however, for backward compatibility with older Node.js versions. 630 631`--preserve-symlinks-main` does not imply `--preserve-symlinks`; it 632is expected that `--preserve-symlinks-main` will be used in addition to 633`--preserve-symlinks` when it is not desirable to follow symlinks before 634resolving relative paths. 635 636See `--preserve-symlinks` for more information. 637 638### `--prof` 639<!-- YAML 640added: v2.0.0 641--> 642 643Generate V8 profiler output. 644 645### `--prof-process` 646<!-- YAML 647added: v5.2.0 648--> 649 650Process V8 profiler output generated using the V8 option `--prof`. 651 652### `--redirect-warnings=file` 653<!-- YAML 654added: v8.0.0 655--> 656 657Write process warnings to the given file instead of printing to stderr. The 658file will be created if it does not exist, and will be appended to if it does. 659If an error occurs while attempting to write the warning to the file, the 660warning will be written to stderr instead. 661 662The `file` name may be an absolute path. If it is not, the default directory it 663will be written to is controlled by the 664[--diagnostic-dir](#cli_diagnostic_dir_directory) command line option. 665 666### `--report-compact` 667<!-- YAML 668added: v12.17.0 669--> 670 671Write reports in a compact format, single-line JSON, more easily consumable 672by log processing systems than the default multi-line format designed for 673human consumption. 674 675### `--report-dir=directory`, `report-directory=directory` 676<!-- YAML 677added: v11.8.0 678changes: 679 - version: v12.17.0 680 pr-url: https://github.com/nodejs/node/pull/32242 681 description: This option is no longer experimental. 682 - version: v12.0.0 683 pr-url: https://github.com/nodejs/node/pull/27312 684 description: Changed from `--diagnostic-report-directory` to 685 `--report-directory` 686--> 687 688Location at which the report will be generated. 689 690### `--report-filename=filename` 691<!-- YAML 692added: v11.8.0 693changes: 694 - version: v12.17.0 695 pr-url: https://github.com/nodejs/node/pull/32242 696 description: This option is no longer experimental. 697 - version: v12.0.0 698 pr-url: https://github.com/nodejs/node/pull/27312 699 description: changed from `--diagnostic-report-filename` to 700 `--report-filename` 701--> 702 703Name of the file to which the report will be written. 704 705### `--report-on-fatalerror` 706<!-- YAML 707added: v11.8.0 708changes: 709 - version: v12.17.0 710 pr-url: https://github.com/nodejs/node/pull/32496 711 description: This option is no longer experimental. 712 - version: v12.0.0 713 pr-url: https://github.com/nodejs/node/pull/27312 714 description: changed from `--diagnostic-report-on-fatalerror` to 715 `--report-on-fatalerror` 716--> 717 718Enables the report to be triggered on fatal errors (internal errors within 719the Node.js runtime such as out of memory) that lead to termination of the 720application. Useful to inspect various diagnostic data elements such as heap, 721stack, event loop state, resource consumption etc. to reason about the fatal 722error. 723 724### `--report-on-signal` 725<!-- YAML 726added: v11.8.0 727changes: 728 - version: v12.17.0 729 pr-url: https://github.com/nodejs/node/pull/32242 730 description: This option is no longer experimental. 731 - version: v12.0.0 732 pr-url: https://github.com/nodejs/node/pull/27312 733 description: changed from `--diagnostic-report-on-signal` to 734 `--report-on-signal` 735--> 736 737Enables report to be generated upon receiving the specified (or predefined) 738signal to the running Node.js process. The signal to trigger the report is 739specified through `--report-signal`. 740 741### `--report-signal=signal` 742<!-- YAML 743added: v11.8.0 744changes: 745 - version: v12.17.0 746 pr-url: https://github.com/nodejs/node/pull/32242 747 description: This option is no longer experimental. 748 - version: v12.0.0 749 pr-url: https://github.com/nodejs/node/pull/27312 750 description: changed from `--diagnostic-report-signal` to 751 `--report-signal` 752--> 753 754Sets or resets the signal for report generation (not supported on Windows). 755Default signal is `SIGUSR2`. 756 757### `--report-uncaught-exception` 758<!-- YAML 759added: v11.8.0 760changes: 761 - version: v12.17.0 762 pr-url: https://github.com/nodejs/node/pull/32242 763 description: This option is no longer experimental. 764 - version: v12.0.0 765 pr-url: https://github.com/nodejs/node/pull/27312 766 description: changed from `--diagnostic-report-uncaught-exception` to 767 `--report-uncaught-exception` 768--> 769 770Enables report to be generated on uncaught exceptions. Useful when inspecting 771the JavaScript stack in conjunction with native stack and other runtime 772environment data. 773 774### `--throw-deprecation` 775<!-- YAML 776added: v0.11.14 777--> 778 779Throw errors for deprecations. 780 781### `--title=title` 782<!-- YAML 783added: v10.7.0 784--> 785 786Set `process.title` on startup. 787 788### `--tls-cipher-list=list` 789<!-- YAML 790added: v4.0.0 791--> 792 793Specify an alternative default TLS cipher list. Requires Node.js to be built 794with crypto support (default). 795 796### `--tls-keylog=file` 797<!-- YAML 798added: v12.16.0 799--> 800 801Log TLS key material to a file. The key material is in NSS `SSLKEYLOGFILE` 802format and can be used by software (such as Wireshark) to decrypt the TLS 803traffic. 804 805### `--tls-max-v1.2` 806<!-- YAML 807added: v12.0.0 808--> 809 810Set [`tls.DEFAULT_MAX_VERSION`][] to 'TLSv1.2'. Use to disable support for 811TLSv1.3. 812 813### `--tls-max-v1.3` 814<!-- YAML 815added: v12.0.0 816--> 817 818Set default [`tls.DEFAULT_MAX_VERSION`][] to 'TLSv1.3'. Use to enable support 819for TLSv1.3. 820 821### `--tls-min-v1.0` 822<!-- YAML 823added: v12.0.0 824--> 825 826Set default [`tls.DEFAULT_MIN_VERSION`][] to 'TLSv1'. Use for compatibility with 827old TLS clients or servers. 828 829### `--tls-min-v1.1` 830<!-- YAML 831added: v12.0.0 832--> 833 834Set default [`tls.DEFAULT_MIN_VERSION`][] to 'TLSv1.1'. Use for compatibility 835with old TLS clients or servers. 836 837### `--tls-min-v1.2` 838<!-- YAML 839added: v12.2.0 840--> 841 842Set default [`tls.DEFAULT_MIN_VERSION`][] to 'TLSv1.2'. This is the default for 84312.x and later, but the option is supported for compatibility with older Node.js 844versions. 845 846### `--tls-min-v1.3` 847<!-- YAML 848added: v12.0.0 849--> 850 851Set default [`tls.DEFAULT_MIN_VERSION`][] to 'TLSv1.3'. Use to disable support 852for TLSv1.2, which is not as secure as TLSv1.3. 853 854### `--trace-deprecation` 855<!-- YAML 856added: v0.8.0 857--> 858 859Print stack traces for deprecations. 860 861### `--trace-event-categories` 862<!-- YAML 863added: v7.7.0 864--> 865 866A comma separated list of categories that should be traced when trace event 867tracing is enabled using `--trace-events-enabled`. 868 869### `--trace-event-file-pattern` 870<!-- YAML 871added: v9.8.0 872--> 873 874Template string specifying the filepath for the trace event data, it 875supports `${rotation}` and `${pid}`. 876 877### `--trace-events-enabled` 878<!-- YAML 879added: v7.7.0 880--> 881 882Enables the collection of trace event tracing information. 883 884### `--trace-exit` 885<!-- YAML 886added: v12.16.0 887--> 888 889Prints a stack trace whenever an environment is exited proactively, 890i.e. invoking `process.exit()`. 891 892### `--trace-sigint` 893<!-- YAML 894added: v12.17.0 895--> 896 897Prints a stack trace on SIGINT. 898 899### `--trace-sync-io` 900<!-- YAML 901added: v2.1.0 902--> 903 904Prints a stack trace whenever synchronous I/O is detected after the first turn 905of the event loop. 906 907### `--trace-tls` 908<!-- YAML 909added: v12.2.0 910--> 911 912Prints TLS packet trace information to `stderr`. This can be used to debug TLS 913connection problems. 914 915### `--trace-uncaught` 916<!-- YAML 917added: v12.16.0 918--> 919 920Print stack traces for uncaught exceptions; usually, the stack trace associated 921with the creation of an `Error` is printed, whereas this makes Node.js also 922print the stack trace associated with throwing the value (which does not need 923to be an `Error` instance). 924 925Enabling this option may affect garbage collection behavior negatively. 926 927### `--trace-warnings` 928<!-- YAML 929added: v6.0.0 930--> 931 932Print stack traces for process warnings (including deprecations). 933 934### `--track-heap-objects` 935<!-- YAML 936added: v2.4.0 937--> 938 939Track heap object allocations for heap snapshots. 940 941### `--unhandled-rejections=mode` 942<!-- YAML 943added: v12.0.0 944--> 945 946By default all unhandled rejections trigger a warning plus a deprecation warning 947for the very first unhandled rejection in case no [`unhandledRejection`][] hook 948is used. 949 950Using this flag allows to change what should happen when an unhandled rejection 951occurs. One of three modes can be chosen: 952 953* `strict`: Raise the unhandled rejection as an uncaught exception. 954* `warn`: Always trigger a warning, no matter if the [`unhandledRejection`][] 955 hook is set or not but do not print the deprecation warning. 956* `none`: Silence all warnings. 957 958### `--use-bundled-ca`, `--use-openssl-ca` 959<!-- YAML 960added: v6.11.0 961--> 962 963Use bundled Mozilla CA store as supplied by current Node.js version 964or use OpenSSL's default CA store. The default store is selectable 965at build-time. 966 967The bundled CA store, as supplied by Node.js, is a snapshot of Mozilla CA store 968that is fixed at release time. It is identical on all supported platforms. 969 970Using OpenSSL store allows for external modifications of the store. For most 971Linux and BSD distributions, this store is maintained by the distribution 972maintainers and system administrators. OpenSSL CA store location is dependent on 973configuration of the OpenSSL library but this can be altered at runtime using 974environment variables. 975 976See `SSL_CERT_DIR` and `SSL_CERT_FILE`. 977 978### `--use-largepages=mode` 979<!-- YAML 980added: v12.17.0 981--> 982 983Re-map the Node.js static code to large memory pages at startup. If supported on 984the target system, this will cause the Node.js static code to be moved onto 2 985MiB pages instead of 4 KiB pages. 986 987The following values are valid for `mode`: 988* `off`: No mapping will be attempted. This is the default. 989* `on`: If supported by the OS, mapping will be attempted. Failure to map will 990 be ignored and a message will be printed to standard error. 991* `silent`: If supported by the OS, mapping will be attempted. Failure to map 992 will be ignored and will not be reported. 993 994### `--v8-options` 995<!-- YAML 996added: v0.1.3 997--> 998 999Print V8 command line options. 1000 1001### `--v8-pool-size=num` 1002<!-- YAML 1003added: v5.10.0 1004--> 1005 1006Set V8's thread pool size which will be used to allocate background jobs. 1007 1008If set to `0` then V8 will choose an appropriate size of the thread pool based 1009on the number of online processors. 1010 1011If the value provided is larger than V8's maximum, then the largest value 1012will be chosen. 1013 1014### `--zero-fill-buffers` 1015<!-- YAML 1016added: v6.0.0 1017--> 1018 1019Automatically zero-fills all newly allocated [`Buffer`][] and [`SlowBuffer`][] 1020instances. 1021 1022### `-c`, `--check` 1023<!-- YAML 1024added: 1025 - v5.0.0 1026 - v4.2.0 1027changes: 1028 - version: v10.0.0 1029 pr-url: https://github.com/nodejs/node/pull/19600 1030 description: The `--require` option is now supported when checking a file. 1031--> 1032 1033Syntax check the script without executing. 1034 1035### `-e`, `--eval "script"` 1036<!-- YAML 1037added: v0.5.2 1038changes: 1039 - version: v5.11.0 1040 pr-url: https://github.com/nodejs/node/pull/5348 1041 description: Built-in libraries are now available as predefined variables. 1042--> 1043 1044Evaluate the following argument as JavaScript. The modules which are 1045predefined in the REPL can also be used in `script`. 1046 1047On Windows, using `cmd.exe` a single quote will not work correctly because it 1048only recognizes double `"` for quoting. In Powershell or Git bash, both `'` 1049and `"` are usable. 1050 1051### `-h`, `--help` 1052<!-- YAML 1053added: v0.1.3 1054--> 1055 1056Print node command line options. 1057The output of this option is less detailed than this document. 1058 1059### `-i`, `--interactive` 1060<!-- YAML 1061added: v0.7.7 1062--> 1063 1064Opens the REPL even if stdin does not appear to be a terminal. 1065 1066### `-p`, `--print "script"` 1067<!-- YAML 1068added: v0.6.4 1069changes: 1070 - version: v5.11.0 1071 pr-url: https://github.com/nodejs/node/pull/5348 1072 description: Built-in libraries are now available as predefined variables. 1073--> 1074 1075Identical to `-e` but prints the result. 1076 1077### `-r`, `--require module` 1078<!-- YAML 1079added: v1.6.0 1080--> 1081 1082Preload the specified module at startup. 1083 1084Follows `require()`'s module resolution 1085rules. `module` may be either a path to a file, or a node module name. 1086 1087### `-v`, `--version` 1088<!-- YAML 1089added: v0.1.3 1090--> 1091 1092Print node's version. 1093 1094## Environment variables 1095 1096### `NODE_DEBUG=module[,…]` 1097<!-- YAML 1098added: v0.1.32 1099--> 1100 1101`','`-separated list of core modules that should print debug information. 1102 1103### `NODE_DEBUG_NATIVE=module[,…]` 1104 1105`','`-separated list of core C++ modules that should print debug information. 1106 1107### `NODE_DISABLE_COLORS=1` 1108<!-- YAML 1109added: v0.3.0 1110--> 1111 1112When set, colors will not be used in the REPL. 1113 1114### `NODE_EXTRA_CA_CERTS=file` 1115<!-- YAML 1116added: v7.3.0 1117--> 1118 1119When set, the well known "root" CAs (like VeriSign) will be extended with the 1120extra certificates in `file`. The file should consist of one or more trusted 1121certificates in PEM format. A message will be emitted (once) with 1122[`process.emitWarning()`][emit_warning] if the file is missing or 1123malformed, but any errors are otherwise ignored. 1124 1125Neither the well known nor extra certificates are used when the `ca` 1126options property is explicitly specified for a TLS or HTTPS client or server. 1127 1128This environment variable is ignored when `node` runs as setuid root or 1129has Linux file capabilities set. 1130 1131### `NODE_ICU_DATA=file` 1132<!-- YAML 1133added: v0.11.15 1134--> 1135 1136Data path for ICU (`Intl` object) data. Will extend linked-in data when compiled 1137with small-icu support. 1138 1139### `NODE_NO_WARNINGS=1` 1140<!-- YAML 1141added: v6.11.0 1142--> 1143 1144When set to `1`, process warnings are silenced. 1145 1146### `NODE_OPTIONS=options...` 1147<!-- YAML 1148added: v8.0.0 1149--> 1150 1151A space-separated list of command line options. `options...` are interpreted 1152before command line options, so command line options will override or 1153compound after anything in `options...`. Node.js will exit with an error if 1154an option that is not allowed in the environment is used, such as `-p` or a 1155script file. 1156 1157In case an option value happens to contain a space (for example a path listed 1158in `--require`), it must be escaped using double quotes. For example: 1159 1160```bash 1161NODE_OPTIONS='--require "./my path/file.js"' 1162``` 1163 1164A singleton flag passed as a command line option will override the same flag 1165passed into `NODE_OPTIONS`: 1166 1167```bash 1168# The inspector will be available on port 5555 1169NODE_OPTIONS='--inspect=localhost:4444' node --inspect=localhost:5555 1170``` 1171 1172A flag that can be passed multiple times will be treated as if its 1173`NODE_OPTIONS` instances were passed first, and then its command line 1174instances afterwards: 1175 1176```bash 1177NODE_OPTIONS='--require "./a.js"' node --require "./b.js" 1178# is equivalent to: 1179node --require "./a.js" --require "./b.js" 1180``` 1181 1182Node.js options that are allowed are: 1183<!-- node-options-node start --> 1184* `--conditions` 1185* `--diagnostic-dir` 1186* `--disable-proto` 1187* `--enable-fips` 1188* `--enable-source-maps` 1189* `--experimental-import-meta-resolve` 1190* `--experimental-json-modules` 1191* `--experimental-loader` 1192* `--experimental-modules` 1193* `--experimental-policy` 1194* `--experimental-repl-await` 1195* `--experimental-specifier-resolution` 1196* `--experimental-vm-modules` 1197* `--experimental-wasi-unstable-preview1` 1198* `--experimental-wasm-modules` 1199* `--force-context-aware` 1200* `--force-fips` 1201* `--frozen-intrinsics` 1202* `--heapsnapshot-signal` 1203* `--http-parser` 1204* `--http-server-default-timeout` 1205* `--icu-data-dir` 1206* `--input-type` 1207* `--insecure-http-parser` 1208* `--inspect-brk` 1209* `--inspect-port`, `--debug-port` 1210* `--inspect-publish-uid` 1211* `--inspect` 1212* `--max-http-header-size` 1213* `--napi-modules` 1214* `--no-deprecation` 1215* `--no-force-async-hooks-checks` 1216* `--no-warnings` 1217* `--openssl-config` 1218* `--pending-deprecation` 1219* `--policy-integrity` 1220* `--preserve-symlinks-main` 1221* `--preserve-symlinks` 1222* `--prof-process` 1223* `--redirect-warnings` 1224* `--report-compact` 1225* `--report-dir`, `--report-directory` 1226* `--report-filename` 1227* `--report-on-fatalerror` 1228* `--report-on-signal` 1229* `--report-signal` 1230* `--report-uncaught-exception` 1231* `--require`, `-r` 1232* `--throw-deprecation` 1233* `--title` 1234* `--tls-cipher-list` 1235* `--tls-keylog` 1236* `--tls-max-v1.2` 1237* `--tls-max-v1.3` 1238* `--tls-min-v1.0` 1239* `--tls-min-v1.1` 1240* `--tls-min-v1.2` 1241* `--tls-min-v1.3` 1242* `--trace-deprecation` 1243* `--trace-event-categories` 1244* `--trace-event-file-pattern` 1245* `--trace-events-enabled` 1246* `--trace-exit` 1247* `--trace-sigint` 1248* `--trace-sync-io` 1249* `--trace-tls` 1250* `--trace-uncaught` 1251* `--trace-warnings` 1252* `--track-heap-objects` 1253* `--unhandled-rejections` 1254* `--use-bundled-ca` 1255* `--use-largepages` 1256* `--use-openssl-ca` 1257* `--v8-pool-size` 1258* `--zero-fill-buffers` 1259<!-- node-options-node end --> 1260 1261V8 options that are allowed are: 1262<!-- node-options-v8 start --> 1263* `--abort-on-uncaught-exception` 1264* `--disallow-code-generation-from-strings` 1265* `--huge-max-old-generation-size` 1266* `--interpreted-frames-native-stack` 1267* `--jitless` 1268* `--max-old-space-size` 1269* `--perf-basic-prof-only-functions` 1270* `--perf-basic-prof` 1271* `--perf-prof-unwinding-info` 1272* `--perf-prof` 1273* `--stack-trace-limit` 1274<!-- node-options-v8 end --> 1275 1276`--perf-basic-prof-only-functions`, `--perf-basic-prof`, 1277`--perf-prof-unwinding-info`, and `--perf-prof` are only available on Linux. 1278 1279### `NODE_PATH=path[:…]` 1280<!-- YAML 1281added: v0.1.32 1282--> 1283 1284`':'`-separated list of directories prefixed to the module search path. 1285 1286On Windows, this is a `';'`-separated list instead. 1287 1288### `NODE_PENDING_DEPRECATION=1` 1289<!-- YAML 1290added: v8.0.0 1291--> 1292 1293When set to `1`, emit pending deprecation warnings. 1294 1295Pending deprecations are generally identical to a runtime deprecation with the 1296notable exception that they are turned *off* by default and will not be emitted 1297unless either the `--pending-deprecation` command line flag, or the 1298`NODE_PENDING_DEPRECATION=1` environment variable, is set. Pending deprecations 1299are used to provide a kind of selective "early warning" mechanism that 1300developers may leverage to detect deprecated API usage. 1301 1302### `NODE_PENDING_PIPE_INSTANCES=instances` 1303 1304Set the number of pending pipe instance handles when the pipe server is waiting 1305for connections. This setting applies to Windows only. 1306 1307### `NODE_PRESERVE_SYMLINKS=1` 1308<!-- YAML 1309added: v7.1.0 1310--> 1311 1312When set to `1`, instructs the module loader to preserve symbolic links when 1313resolving and caching modules. 1314 1315### `NODE_REDIRECT_WARNINGS=file` 1316<!-- YAML 1317added: v8.0.0 1318--> 1319 1320When set, process warnings will be emitted to the given file instead of 1321printing to stderr. The file will be created if it does not exist, and will be 1322appended to if it does. If an error occurs while attempting to write the 1323warning to the file, the warning will be written to stderr instead. This is 1324equivalent to using the `--redirect-warnings=file` command-line flag. 1325 1326### `NODE_REPL_HISTORY=file` 1327<!-- YAML 1328added: v3.0.0 1329--> 1330 1331Path to the file used to store the persistent REPL history. The default path is 1332`~/.node_repl_history`, which is overridden by this variable. Setting the value 1333to an empty string (`''` or `' '`) disables persistent REPL history. 1334 1335### `NODE_REPL_EXTERNAL_MODULE=file` 1336<!-- YAML 1337added: v12.16.0 1338--> 1339 1340Path to a Node.js module which will be loaded in place of the built-in REPL. 1341Overriding this value to an empty string (`''`) will use the built-in REPL. 1342 1343### `NODE_TLS_REJECT_UNAUTHORIZED=value` 1344 1345If `value` equals `'0'`, certificate validation is disabled for TLS connections. 1346This makes TLS, and HTTPS by extension, insecure. The use of this environment 1347variable is strongly discouraged. 1348 1349### `NODE_V8_COVERAGE=dir` 1350 1351When set, Node.js will begin outputting [V8 JavaScript code coverage][] and 1352[Source Map][] data to the directory provided as an argument (coverage 1353information is written as JSON to files with a `coverage` prefix). 1354 1355`NODE_V8_COVERAGE` will automatically propagate to subprocesses, making it 1356easier to instrument applications that call the `child_process.spawn()` family 1357of functions. `NODE_V8_COVERAGE` can be set to an empty string, to prevent 1358propagation. 1359 1360#### Coverage output 1361 1362Coverage is output as an array of [ScriptCoverage][] objects on the top-level 1363key `result`: 1364 1365```json 1366{ 1367 "result": [ 1368 { 1369 "scriptId": "67", 1370 "url": "internal/tty.js", 1371 "functions": [] 1372 } 1373 ] 1374} 1375``` 1376 1377#### Source map cache 1378 1379> Stability: 1 - Experimental 1380 1381If found, source map data is appended to the top-level key `source-map-cache` 1382on the JSON coverage object. 1383 1384`source-map-cache` is an object with keys representing the files source maps 1385were extracted from, and values which include the raw source-map URL 1386(in the key `url`), the parsed Source Map v3 information (in the key `data`), 1387and the line lengths of the source file (in the key `lineLengths`). 1388 1389```json 1390{ 1391 "result": [ 1392 { 1393 "scriptId": "68", 1394 "url": "file:///absolute/path/to/source.js", 1395 "functions": [] 1396 } 1397 ], 1398 "source-map-cache": { 1399 "file:///absolute/path/to/source.js": { 1400 "url": "./path-to-map.json", 1401 "data": { 1402 "version": 3, 1403 "sources": [ 1404 "file:///absolute/path/to/original.js" 1405 ], 1406 "names": [ 1407 "Foo", 1408 "console", 1409 "info" 1410 ], 1411 "mappings": "MAAMA,IACJC,YAAaC", 1412 "sourceRoot": "./" 1413 }, 1414 "lineLengths": [ 1415 13, 1416 62, 1417 38, 1418 27 1419 ] 1420 } 1421 } 1422} 1423``` 1424 1425### `OPENSSL_CONF=file` 1426<!-- YAML 1427added: v6.11.0 1428--> 1429 1430Load an OpenSSL configuration file on startup. Among other uses, this can be 1431used to enable FIPS-compliant crypto if Node.js is built with `./configure 1432--openssl-fips`. 1433 1434If the [`--openssl-config`][] command line option is used, the environment 1435variable is ignored. 1436 1437### `SSL_CERT_DIR=dir` 1438<!-- YAML 1439added: v7.7.0 1440--> 1441 1442If `--use-openssl-ca` is enabled, this overrides and sets OpenSSL's directory 1443containing trusted certificates. 1444 1445Be aware that unless the child environment is explicitly set, this environment 1446variable will be inherited by any child processes, and if they use OpenSSL, it 1447may cause them to trust the same CAs as node. 1448 1449### `SSL_CERT_FILE=file` 1450<!-- YAML 1451added: v7.7.0 1452--> 1453 1454If `--use-openssl-ca` is enabled, this overrides and sets OpenSSL's file 1455containing trusted certificates. 1456 1457Be aware that unless the child environment is explicitly set, this environment 1458variable will be inherited by any child processes, and if they use OpenSSL, it 1459may cause them to trust the same CAs as node. 1460 1461### `UV_THREADPOOL_SIZE=size` 1462 1463Set the number of threads used in libuv's threadpool to `size` threads. 1464 1465Asynchronous system APIs are used by Node.js whenever possible, but where they 1466do not exist, libuv's threadpool is used to create asynchronous node APIs based 1467on synchronous system APIs. Node.js APIs that use the threadpool are: 1468 1469* all `fs` APIs, other than the file watcher APIs and those that are explicitly 1470 synchronous 1471* asynchronous crypto APIs such as `crypto.pbkdf2()`, `crypto.scrypt()`, 1472 `crypto.randomBytes()`, `crypto.randomFill()`, `crypto.generateKeyPair()` 1473* `dns.lookup()` 1474* all `zlib` APIs, other than those that are explicitly synchronous 1475 1476Because libuv's threadpool has a fixed size, it means that if for whatever 1477reason any of these APIs takes a long time, other (seemingly unrelated) APIs 1478that run in libuv's threadpool will experience degraded performance. In order to 1479mitigate this issue, one potential solution is to increase the size of libuv's 1480threadpool by setting the `'UV_THREADPOOL_SIZE'` environment variable to a value 1481greater than `4` (its current default value). For more information, see the 1482[libuv threadpool documentation][]. 1483 1484## Useful V8 options 1485 1486V8 has its own set of CLI options. Any V8 CLI option that is provided to `node` 1487will be passed on to V8 to handle. V8's options have _no stability guarantee_. 1488The V8 team themselves don't consider them to be part of their formal API, 1489and reserve the right to change them at any time. Likewise, they are not 1490covered by the Node.js stability guarantees. Many of the V8 1491options are of interest only to V8 developers. Despite this, there is a small 1492set of V8 options that are widely applicable to Node.js, and they are 1493documented here: 1494 1495### `--max-old-space-size=SIZE` (in megabytes) 1496 1497Sets the max memory size of V8's old memory section. As memory 1498consumption approaches the limit, V8 will spend more time on 1499garbage collection in an effort to free unused memory. 1500 1501On a machine with 2GB of memory, consider setting this to 15021536 (1.5GB) to leave some memory for other uses and avoid swapping. 1503 1504```console 1505$ node --max-old-space-size=1536 index.js 1506``` 1507 1508[`--openssl-config`]: #cli_openssl_config_file 1509[`Buffer`]: buffer.html#buffer_class_buffer 1510[`SlowBuffer`]: buffer.html#buffer_class_slowbuffer 1511[`NODE_OPTIONS`]: #cli_node_options_options 1512[`process.setUncaughtExceptionCaptureCallback()`]: process.html#process_process_setuncaughtexceptioncapturecallback_fn 1513[`tls.DEFAULT_MAX_VERSION`]: tls.html#tls_tls_default_max_version 1514[`tls.DEFAULT_MIN_VERSION`]: tls.html#tls_tls_default_min_version 1515[`unhandledRejection`]: process.html#process_event_unhandledrejection 1516[Chrome DevTools Protocol]: https://chromedevtools.github.io/devtools-protocol/ 1517[REPL]: repl.html 1518[ScriptCoverage]: https://chromedevtools.github.io/devtools-protocol/tot/Profiler#type-ScriptCoverage 1519[Source Map]: https://sourcemaps.info/spec.html 1520[Subresource Integrity]: https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity 1521[V8 JavaScript code coverage]: https://v8project.blogspot.com/2017/12/javascript-code-coverage.html 1522[context-aware]: addons.html#addons_context_aware_addons 1523[customizing ESM specifier resolution]: esm.html#esm_customizing_esm_specifier_resolution_algorithm 1524[debugger]: debugger.html 1525[debugging security implications]: https://nodejs.org/en/docs/guides/debugging-getting-started/#security-implications 1526[emit_warning]: process.html#process_process_emitwarning_warning_type_code_ctor 1527[experimental ECMAScript Module loader]: esm.html#esm_experimental_loaders 1528[jitless]: https://v8.dev/blog/jitless 1529[libuv threadpool documentation]: https://docs.libuv.org/en/latest/threadpool.html 1530[remote code execution]: https://www.owasp.org/index.php/Code_Injection 1531