1NODE(1) BSD General Commands Manual NODE(1)
2
4 node — server-side JavaScript runtime
5
7 node [options] [v8-options] [-e string | script.js | -] [--]
8 [arguments ...]
9 node inspect [-e string | script.js | - | <host>:<port>] ...
10 node [--v8-options]
11
13 Node.js is a set of libraries for JavaScript which allows it to be used
14 outside of the browser. It is primarily focused on creating simple,
15 easy-to-build network clients and servers.
16
17 Execute node without arguments to start a REPL.
18
20 - Alias for stdin, analogous to the use of - in other command-line
21 utilities. The executed script is read from stdin, and remaining
22 arguments are passed to the script.
23
24 -- Indicate the end of command-line options. Pass the rest of the
25 arguments to the script.
26
27 If no script filename or eval/print script is supplied prior to
28 this, then the next argument will be used as a script filename.
29
30 --abort-on-uncaught-exception
31 Aborting instead of exiting causes a core file to be generated
32 for analysis.
33
34 --completion-bash
35 Print source-able bash completion script for Node.js.
36
37 -C, --conditions string
38 Use custom conditional exports conditions. string
39
40 --cpu-prof
41 Start the V8 CPU profiler on start up, and write the CPU profile
42 to disk before exit. If --cpu-prof-dir is not specified, the pro‐
43 file will be written to the current working directory with a gen‐
44 erated file name.
45
46 --cpu-prof-dir
47 The directory where the CPU profiles generated by --cpu-prof will
48 be placed. The default value is controlled by the
49 --diagnostic-dir. command-line option.
50
51 --cpu-prof-interval
52 The sampling interval in microseconds for the CPU profiles gener‐
53 ated by --cpu-prof. The default is 1000.
54
55 --cpu-prof-name
56 File name of the V8 CPU profile generated with --cpu-prof.
57
58 --diagnostic-dir
59 Set the directory for all diagnostic output files. Default is
60 current working directory. Set the directory to which all diag‐
61 nostic output files will be written to. Defaults to current
62 working directory. Affects the default output directory of:
63 --cpu-prof-dir. --heap-prof-dir. --redirect-warnings.
64
65 --disable-proto=mode
66 Disable the `Object.prototype.__proto__` property. If mode is
67 `delete`, the property will be removed entirely. If mode is
68 `throw`, accesses to the property will throw an exception with
69 the code `ERR_PROTO_ACCESS`.
70
71 --disallow-code-generation-from-strings
72 Make built-in language features like `eval` and `new Function`
73 that generate code from strings throw an exception instead. This
74 does not affect the Node.js `vm` module.
75
76 --enable-fips
77 Enable FIPS-compliant crypto at startup. Requires Node.js to be
78 built with ./configure --openssl-fips.
79
80 --enable-source-maps
81 Enable Source Map V3 support for stack traces.
82
83 --experimental-default-type=type
84 Interpret as either ES modules or CommonJS modules input via
85 --eval or STDIN, when --input-type is unspecified;
86
87 --experimental-global-customevent
88 Expose the CustomEvent on the global scope.
89
90 --experimental-global-webcrypto
91 Expose the Web Crypto API on the global scope.
92
93 --experimental-import-meta-resolve
94 Enable experimental ES modules support for import.meta.resolve().
95
96 --experimental-loader=module
97 Specify the module to use as a custom module loader.
98
99 --experimental-network-imports
100 Enable experimental support for loading modules using `import`
101 over `https:`.
102
103 --experimental-policy
104 Use the specified file as a security policy.
105
106 --experimental-shadow-realm
107 Use this flag to enable ShadowRealm support.
108
109 --experimental-test-coverage
110 Enable code coverage in the test runner.
111
112 --no-experimental-fetch
113 Disable experimental support for the Fetch API.
114
115 --no-experimental-repl-await
116 Disable top-level await keyword support in REPL.
117
118 --experimental-specifier-resolution
119 Select extension resolution algorithm for ES Modules; either 'ex‐
120 plicit' (default) or 'node'.
121
122 --experimental-vm-modules
123 Enable experimental ES module support in VM module.
124
125 --experimental-wasi-unstable-preview1
126 Enable experimental WebAssembly System Interface support. This
127 flag is no longer required as WASI is enabled by default.
128
129 --experimental-wasm-modules
130 Enable experimental WebAssembly module support.
131
132 --force-context-aware
133 Disable loading native addons that are not context-aware.
134
135 --force-fips
136 Force FIPS-compliant crypto on startup (Cannot be disabled from
137 script code). Same requirements as --enable-fips.
138
139 --frozen-intrinsics
140 Enable experimental frozen intrinsics support.
141
142 --heapsnapshot-near-heap-limit=max_count
143 Generate heap snapshot when the V8 heap usage is approaching the
144 heap limit. No more than the specified number of snapshots will
145 be generated.
146
147 --heapsnapshot-signal=signal
148 Generate heap snapshot on specified signal.
149
150 --heap-prof
151 Start the V8 heap profiler on start up, and write the heap pro‐
152 file to disk before exit. If --heap-prof-dir is not specified,
153 the profile will be written to the current working directory with
154 a generated file name.
155
156 --heap-prof-dir
157 The directory where the heap profiles generated by --heap-prof
158 will be placed. The default value is controlled by the
159 --diagnostic-dir. command-line option.
160
161 --heap-prof-interval
162 The average sampling interval in bytes for the heap profiles gen‐
163 erated by --heap-prof. The default is 512 * 1024.
164
165 --heap-prof-name
166 File name of the V8 heap profile generated with --heap-prof.
167
168 --icu-data-dir=file
169 Specify ICU data load path. Overrides NODE_ICU_DATA.
170
171 --input-type=type
172 Set the module resolution type for input via --eval, --print or
173 STDIN.
174
175 --inspect-brk=[host:]port
176 Activate inspector on host:port and break at start of user
177 script.
178
179 --inspect-port=[host:]port
180 Set the host:port to be used when the inspector is activated.
181
182 --inspect-publish-uid=stderr,http
183 Specify how the inspector WebSocket URL is exposed. Valid values
184 are stderr and http. Default is stderr,http.
185
186 --inspect=[host:]port
187 Activate inspector on host:port. Default is 127.0.0.1:9229.
188
189 V8 Inspector integration allows attaching Chrome DevTools and
190 IDEs to Node.js instances for debugging and profiling. It uses
191 the Chrome DevTools Protocol.
192
193 --insecure-http-parser
194 Use an insecure HTTP parser that accepts invalid HTTP headers.
195 This may allow interoperability with non-conformant HTTP imple‐
196 mentations. It may also allow request smuggling and other HTTP
197 attacks that rely on invalid headers being accepted. Avoid using
198 this option.
199
200 --jitless
201 Disable runtime allocation of executable memory. This may be re‐
202 quired on some platforms for security reasons. It can also reduce
203 attack surface on other platforms, but the performance impact may
204 be severe.
205
206 This flag is inherited from V8 and is subject to change upstream.
207 It may disappear in a non-semver-major release.
208
209 --max-http-header-size=size
210 Specify the maximum size of HTTP headers in bytes. Defaults to 16
211 KiB.
212
213 --napi-modules
214 This option is a no-op. It is kept for compatibility.
215
216 --no-deprecation
217 Silence deprecation warnings.
218
219 --no-extra-info-on-fatal-exception
220 Hide extra information on fatal exception that causes exit.
221
222 --no-force-async-hooks-checks
223 Disable runtime checks for `async_hooks`. These will still be
224 enabled dynamically when `async_hooks` is enabled.
225
226 --no-addons
227 Disable the `node-addons` exports condition as well as disable
228 loading native addons. When `--no-addons` is specified, calling
229 `process.dlopen` or requiring a native C++ addon will fail and
230 throw an exception.
231
232 --no-global-search-paths
233 Do not search modules from global paths.
234
235 --no-warnings
236 Silence all process warnings (including deprecations).
237
238 --node-memory-debug
239 Enable extra debug checks for memory leaks in Node.js internals.
240 This is usually only useful for developers debugging Node.js it‐
241 self.
242
243 --openssl-config=file
244 Load an OpenSSL configuration file on startup. Among other uses,
245 this can be used to enable FIPS-compliant crypto if Node.js is
246 built with ./configure --openssl-fips.
247
248 --pending-deprecation
249 Emit pending deprecation warnings.
250
251 --policy-integrity=sri
252 Instructs Node.js to error prior to running any code if the pol‐
253 icy does not have the specified integrity. It expects a Subre‐
254 source Integrity string as a parameter.
255
256 --preserve-symlinks
257 Instructs the module loader to preserve symbolic links when re‐
258 solving and caching modules other than the main module.
259
260 --preserve-symlinks-main
261 Instructs the module loader to preserve symbolic links when re‐
262 solving and caching the main module.
263
264 --prof Generate V8 profiler output.
265
266 --prof-process
267 Process V8 profiler output generated using the V8 option --prof.
268
269 --redirect-warnings=file
270 Write process warnings to the given file instead of printing to
271 stderr.
272
273 --report-compact
274 Write diagnostic reports in a compact format, single-line JSON.
275
276 --report-dir --report-directory
277 Location at which the diagnostic report will be generated. The
278 `file` name may be an absolute path. If it is not, the default
279 directory it will be written to is controlled by the
280 --diagnostic-dir. command-line option.
281
282 --report-filename
283 Name of the file to which the diagnostic report will be written.
284
285 --report-on-fatalerror
286 Enables the diagnostic report to be triggered on fatal errors
287 (internal errors within the Node.js runtime such as out of mem‐
288 ory) that leads to termination of the application. Useful to in‐
289 spect various diagnostic data elements such as heap, stack, event
290 loop state, resource consumption etc. to reason about the fatal
291 error.
292
293 --report-on-signal
294 Enables diagnostic report to be generated upon receiving the
295 specified (or predefined) signal to the running Node.js process.
296 Default signal is SIGUSR2.
297
298 --report-signal
299 Sets or resets the signal for diagnostic report generation (not
300 supported on Windows). Default signal is SIGUSR2.
301
302 --report-uncaught-exception
303 Enables diagnostic report to be generated on un-caught excep‐
304 tions. Useful when inspecting JavaScript stack in conjunction
305 with native stack and other runtime environment data.
306
307 --secure-heap=n
308 Specify the size of the OpenSSL secure heap. Any value less than
309 2 disables the secure heap. The default is 0. The value must be a
310 power of two.
311
312 --secure-heap-min=n
313 Specify the minimum allocation from the OpenSSL secure heap. The
314 default is 2. The value must be a power of two.
315
316 --test Starts the Node.js command line test runner.
317
318 --test-concurrency
319 The maximum number of test files that the test runner CLI will
320 execute concurrently.
321
322 --test-name-pattern
323 A regular expression that configures the test runner to only exe‐
324 cute tests whose name matches the provided pattern.
325
326 --test-reporter
327 A test reporter to use when running tests.
328
329 --test-reporter-destination
330 The destination for the corresponding test reporter.
331
332 --test-only
333 Configures the test runner to only execute top level tests that
334 have the `only` option set.
335
336 --test-shard
337 Test suite shard to execute in a format of <index>/<total>.
338
339 --throw-deprecation
340 Throw errors for deprecations.
341
342 --title=title
343 Specify process.title on startup.
344
345 --tls-cipher-list=list
346 Specify an alternative default TLS cipher list. Requires Node.js
347 to be built with crypto support. (Default)
348
349 --tls-keylog=file
350 Log TLS key material to a file. The key material is in NSS SS‐
351 LKEYLOGFILE format and can be used by software (such as Wire‐
352 shark) to decrypt the TLS traffic.
353
354 --tls-max-v1.2
355 Set default maxVersion to 'TLSv1.2'. Use to disable support for
356 TLSv1.3.
357
358 --tls-max-v1.3
359 Set default maxVersion to 'TLSv1.3'. Use to enable support for
360 TLSv1.3.
361
362 --tls-min-v1.0
363 Set default minVersion to 'TLSv1'. Use for compatibility with old
364 TLS clients or servers.
365
366 --tls-min-v1.1
367 Set default minVersion to 'TLSv1.1'. Use for compatibility with
368 old TLS clients or servers.
369
370 --tls-min-v1.2
371 Set default minVersion to 'TLSv1.2'. This is the default for 12.x
372 and later, but the option is supported for compatibility with
373 older Node.js versions.
374
375 --tls-min-v1.3
376 Set default minVersion to 'TLSv1.3'. Use to disable support for
377 TLSv1.2 in favour of TLSv1.3, which is more secure.
378
379 --trace-atomics-wait
380 Print short summaries of calls to Atomics.wait(). This flag is
381 deprecated.
382
383 --trace-deprecation
384 Print stack traces for deprecations.
385
386 --trace-event-categories categories
387 A comma-separated list of categories that should be traced when
388 trace event tracing is enabled using --trace-events-enabled.
389
390 --trace-event-file-pattern pattern
391 Template string specifying the filepath for the trace event data,
392 it supports ${rotation} and ${pid}.
393
394 --trace-events-enabled
395 Enable the collection of trace event tracing information.
396
397 --trace-exit
398 Prints a stack trace whenever an environment is exited proac‐
399 tively, i.e. invoking `process.exit()`.
400
401 --trace-sigint
402 Prints a stack trace on SIGINT.
403
404 --trace-sync-io
405 Print a stack trace whenever synchronous I/O is detected after
406 the first turn of the event loop.
407
408 --trace-tls
409 Prints TLS packet trace information to stderr.
410
411 --trace-uncaught
412 Print stack traces for uncaught exceptions; usually, the stack
413 trace associated with the creation of an Error is printed,
414 whereas this makes Node.js also print the stack trace associated
415 with throwing the value (which does not need to be an Error in‐
416 stance).
417
418 Enabling this option may affect garbage collection behavior nega‐
419 tively.
420
421 --trace-warnings
422 Print stack traces for process warnings (including deprecations).
423
424 --track-heap-objects
425 Track heap object allocations for heap snapshots.
426
427 --unhandled-rejections=mode
428 Define the behavior for unhandled rejections. Can be one of
429 `strict` (raise an error), `warn` (enforce warnings) or `none`
430 (silence warnings).
431
432 --use-bundled-ca, --use-openssl-ca
433 Use bundled Mozilla CA store as supplied by current Node.js ver‐
434 sion or use OpenSSL's default CA store. The default store is se‐
435 lectable at build-time.
436
437 The bundled CA store, as supplied by Node.js, is a snapshot of
438 Mozilla CA store that is fixed at release time. It is identical
439 on all supported platforms.
440
441 Using OpenSSL store allows for external modifications of the
442 store. For most Linux and BSD distributions, this store is main‐
443 tained by the distribution maintainers and system administrators.
444 OpenSSL CA store location is dependent on configuration of the
445 OpenSSL library but this can be altered at runtime using environ‐
446 ment variables.
447
448 See SSL_CERT_DIR and SSL_CERT_FILE.
449
450 --use-largepages=mode
451 Re-map the Node.js static code to large memory pages at startup.
452 If supported on the target system, this will cause the Node.js
453 static code to be moved onto 2 MiB pages instead of 4 KiB pages.
454
455 mode must have one of the following values: `off` (the default
456 value, meaning do not map), `on` (map and ignore failure, report‐
457 ing it to stderr), or `silent` (map and silently ignore failure).
458
459 --v8-options
460 Print V8 command-line options.
461
462 --v8-pool-size=num
463 Set V8's thread pool size which will be used to allocate back‐
464 ground jobs. If set to 0 then V8 will choose an appropriate size
465 of the thread pool based on the number of online processors. If
466 the value provided is larger than V8's maximum, then the largest
467 value will be chosen.
468
469 --zero-fill-buffers
470 Automatically zero-fills all newly allocated Buffer and Slow‐
471 Buffer instances.
472
473 -c, --check
474 Check the script's syntax without executing it. Exits with an
475 error code if script is invalid.
476
477 -e, --eval string
478 Evaluate string as JavaScript.
479
480 -h, --help
481 Print command-line options. The output of this option is less
482 detailed than this document.
483
484 -i, --interactive
485 Open the REPL even if stdin does not appear to be a terminal.
486
487 -p, --print string
488 Identical to -e, but prints the result.
489
490 -r, --require module
491 Preload the specified module at startup. Follows `require()`'s
492 module resolution rules. module may be either a path to a file,
493 or a Node.js module name.
494
495 -v, --version
496 Print node's version.
497
499 FORCE_COLOR
500 Used to enable ANSI colorized output. The value may be one of: 1
501 , true , or an empty string to indicate 16-color support, 2 to
502 indicate 256-color support, or 3 to indicate 16 million-color
503 support. When used and set to a supported value, both the
504 NO_COLOR and NODE_DISABLE_COLORS environment variables are ig‐
505 nored. Any other value will result in colorized output being dis‐
506 abled.
507
508 NO_COLOR
509 Alias for NODE_DISABLE_COLORS
510
511 NODE_DEBUG modules...
512 Comma-separated list of core modules that should print debug in‐
513 formation.
514
515 NODE_DEBUG_NATIVE modules...
516 Comma-separated list of C++ core modules that should print debug
517 information.
518
519 NODE_DISABLE_COLORS
520 When set to 1, colors will not be used in the REPL.
521
522 NODE_EXTRA_CA_CERTS file
523 When set, the well-known “root” CAs (like VeriSign) will be ex‐
524 tended with the extra certificates in file. The file should con‐
525 sist of one or more trusted certificates in PEM format.
526
527 If file is missing or misformatted, a message will be emitted
528 once using process.emitWarning(), but any errors are otherwise
529 ignored.
530
531 This environment variable is ignored when `node` runs as setuid
532 root or has Linux file capabilities set.
533
534 The NODE_EXTRA_CA_CERTS environment variable is only read when
535 the Node.js process is first launched. Changing the value at
536 runtime using process.env.NODE_EXTRA_CA_CERTS has no effect on
537 the current process.
538
539 NODE_ICU_DATA file
540 Data path for ICU (Intl object) data. Will extend linked-in data
541 when compiled with small-icu support.
542
543 NODE_NO_WARNINGS
544 When set to 1, process warnings are silenced.
545
546 NODE_OPTIONS options...
547 A space-separated list of command-line options, which are inter‐
548 preted as if they had been specified on the command line before
549 the actual command (so they can be overridden). Node.js will
550 exit with an error if an option that is not allowed in the envi‐
551 ronment is used, such as --print or a script file.
552
553 NODE_PATH directories...
554 A colon-separated list of directories prefixed to the module
555 search path.
556
557 NODE_PENDING_DEPRECATION
558 When set to 1, emit pending deprecation warnings.
559
560 NODE_PRESERVE_SYMLINKS
561 When set to 1, the module loader preserves symbolic links when
562 resolving and caching modules.
563
564 NODE_REDIRECT_WARNINGS file
565 Write process warnings to the given file instead of printing to
566 stderr. Equivalent to passing --redirect-warnings file on the
567 command line.
568
569 NODE_REPL_HISTORY file
570 Path to the file used to store persistent REPL history. The de‐
571 fault path is ~/.node_repl_history, which is overridden by this
572 variable. Setting the value to an empty string ("" or " ") will
573 disable persistent REPL history.
574
575 NODE_REPL_EXTERNAL_MODULE file
576 Path to a Node.js module which will be loaded in place of the
577 built-in REPL. Overriding this value to an empty string (`''`)
578 will use the built-in REPL.
579
580 NODE_SKIP_PLATFORM_CHECK
581 When set to 1, the check for a supported platform is skipped dur‐
582 ing Node.js startup. Node.js might not execute correctly. Any
583 issues encountered on unsupported platforms will not be fixed.
584
585 NODE_TLS_REJECT_UNAUTHORIZED
586 When set to 0, TLS certificate validation is disabled.
587
588 NODE_V8_COVERAGE dir
589 When set, Node.js writes JavaScript code coverage information to
590 dir.
591
592 OPENSSL_CONF file
593 Load an OpenSSL configuration file on startup. Among other uses,
594 this can be used to enable FIPS-compliant crypto if Node.js is
595 built with ./configure --openssl-fips.
596
597 If the --openssl-config command-line option is used, this envi‐
598 ronment variable is ignored.
599
600 SSL_CERT_DIR dir
601 If --use-openssl-ca is enabled, this overrides and sets OpenSSL's
602 directory containing trusted certificates.
603
604 SSL_CERT_FILE file
605 If --use-openssl-ca is enabled, this overrides and sets OpenSSL's
606 file containing trusted certificates.
607
608 TZ Specify the timezone configuration.
609
610 UV_THREADPOOL_SIZE size
611 Sets the number of threads used in libuv's threadpool to size.
612
614 Bugs are tracked in GitHub Issues: https://github.com/nodejs/node/issues
615
617 Copyright Node.js contributors. Node.js is available under the MIT li‐
618 cense.
619
620 Node.js also includes external libraries that are available under a vari‐
621 ety of licenses. See https://github.com/nodejs/node/blob/HEAD/LICENSE
622 for the full license text.
623
625 Website: https://nodejs.org/
626
627 Documentation: https://nodejs.org/api/
628
629 GitHub repository and issue tracker: https://github.com/nodejs/node
630
631 IRC (general questions): libera.chat #node.js (unofficial)
632
634 Written and maintained by 1000+ contributors:
635 https://github.com/nodejs/node/blob/HEAD/AUTHORS
636
637 December 17, 2023