Synopsis
Program Entry Point
The program entry point is a specifier-like string. If the string is not an absolute path, it’s resolved as a relative path from the current working directory. That entry point string is then resolved as if it’s been requested byrequire() from the current working directory.
By default, the resolved path is loaded as if it’s been requested by require(), unless:
- The program was started with a command-line flag that forces the entry point to be loaded with ECMAScript module loader, such as
--import - The file has an
.mjs,.mtsor.wasmextension - The file does not have a
.cjsextension, and the nearest parentpackage.jsonfile contains a top-level"type"field with a value of"module"
Options
All options, including V8 options, allow words to be separated by both dashes (-) or underscores (_). For example, --pending-deprecation is equivalent to --pending_deprecation.
-
Alias for stdin. Analogous to the use of - in other command-line utilities, meaning that the script is read from stdin, and the rest of the options are passed to that script.
--
Indicate the end of node options. Pass the rest of the arguments to the script. If no script filename or eval/print script is supplied prior to this, then the next argument is used as a script filename.
--abort-on-uncaught-exception
Aborting instead of exiting causes a core file to be generated for post-mortem analysis using a debugger (such as lldb, gdb, and mdb).
--allow-addons
Stability: 1.1 - Active development
ERR_DLOPEN_DISABLED unless the user explicitly passes the --allow-addons flag when starting Node.js.
--allow-child-process
Stability: 1.1 - Active development
ERR_ACCESS_DENIED unless the user explicitly passes the --allow-child-process flag when starting Node.js.
--allow-fs-read
This flag configures file system read permissions using the Permission Model.
The valid arguments for the --allow-fs-read flag are:
*- To allow allFileSystemReadoperations- Multiple paths can be allowed using multiple
--allow-fs-readflags
--allow-fs-read=/folder1/ --allow-fs-read=/folder2/
--allow-fs-write
This flag configures file system write permissions using the Permission Model.
The valid arguments for the --allow-fs-write flag are:
*- To allow allFileSystemWriteoperations- Multiple paths can be allowed using multiple
--allow-fs-writeflags
--allow-fs-write=/folder1/ --allow-fs-write=/folder2/
-c, --check
Syntax check the script without executing.
-e, --eval "script"
Evaluate the following argument as JavaScript. The modules which are predefined in the REPL can also be used in script.
On Windows, using cmd.exe a single quote will not work correctly because it only recognizes double " for quoting. In Powershell or Git bash, both ' and " are usable.
--env-file=file
Loads environment variables from a file relative to the current directory, making them available to applications on process.env. The environment variables which configure Node.js, such as NODE_OPTIONS, are parsed and applied.
You can pass multiple --env-file arguments. Subsequent files override pre-existing variables defined in previous files.
=:
--env-file-if-exists=file
Behavior is the same as --env-file, but an error is not thrown if the file does not exist.
--experimental-sea-config
Stability: 1 - Experimental
--experimental-vm-modules
Enable experimental ES Module support in the node:vm module.
--expose-gc
Stability: 1 - Experimental. This flag is inherited from V8 and is subject to change upstream.
-h, --help
Print node command-line options. The output of this option is less detailed than this document.
--import=module
Stability: 1 - Experimental
--require to load a CommonJS module. Modules preloaded with --require will run before modules preloaded with --import.
--input-type=type
This configures Node.js to interpret --eval or STDIN input as CommonJS or as an ES module. Valid values are "commonjs", "module", "module-typescript" and "commonjs-typescript".
--inspect[=[host:]port]
Activate inspector on host:port. Default is 127.0.0.1:9229. If port 0 is specified, a random available port will be used.
V8 inspector integration allows tools such as Chrome DevTools and IDEs to debug and profile Node.js instances.
--inspect-brk[=[host:]port]
Activate inspector on host:port and break at start of user script. Default host:port is 127.0.0.1:9229. If port 0 is specified, a random available port will be used.
--inspect-wait[=[host:]port]
Activate inspector on host:port and wait for debugger to be attached. Default host:port is 127.0.0.1:9229. If port 0 is specified, a random available port will be used.
-i, --interactive
Opens the REPL even if stdin does not appear to be a terminal.
--max-http-header-size=size
Specify the maximum size, in bytes, of HTTP headers. Defaults to 16 KiB.
--no-addons
Disable the node-addons exports condition as well as disable loading native addons. When --no-addons is specified, calling process.dlopen or requiring a native C++ addon will fail and throw an exception.
--no-warnings
Silence all process warnings (including deprecations).
-p, --print "script"
Identical to -e but prints the result.
-r, --require module
Preload the specified module at startup. Follows require()’s module resolution rules. module may be either a path to a file, or a node module name.
--test
Starts the Node.js test runner. This flag cannot be combined with --watch-path, --check, --eval, --interactive, or the inspector.
--trace-warnings
Print stack traces for process warnings (including deprecations).
-v, --version
Print node’s version.
--watch
Starts Node.js in watch mode. When in watch mode, changes in the watched files cause the Node.js process to restart.
--watch-path
Starts Node.js in watch mode and specifies what paths to watch. When in watch mode, changes in the watched paths cause the Node.js process to restart.
Environment Variables
NODE_OPTIONS
A space-separated list of command-line options. options... are interpreted before command-line options, so command-line options will override or compound after anything in options....
NODE_PATH
A colon-separated (: on Unix, ; on Windows) list of directories prefixed to the module search path.
NODE_REPL_HISTORY
When a valid path is given, persistent REPL history will be saved to the specified file rather than .node_repl_history in the user’s home directory.