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