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