Table of Contents

About

node is a interactive cli.

When executed without arguments, it will start in a REPL mode

Usage

node [options] [ -e script | script.js ] [arguments]
node debug script.js [arguments]
Options Description
-v, –version print Node.js version
-e, –eval script evaluate script
-p, –print evaluate script and print result
-c, –check syntax check script without executing
-i, –interactive always enter the REPL even if stdin does not appear to be a terminal
-r, –require module to preload (option can be repeated)
–no-deprecation silence deprecation warnings
–trace-deprecation show stack traces on deprecations
–throw-deprecation throw an exception anytime a deprecated function is used
–no-warnings silence all process warnings
–trace-warnings show stack traces on process warnings
–trace-sync-io show stack trace when use of sync IO is detected after the first tick
–track-heap-objects track heap object allocations for heap snapshots
–prof-process process v8 profiler output generated using –prof
–zero-fill-buffers automatically zero-fill all newly allocated Buffer and SlowBuffer instances
–v8-options print v8 command line options
–v8-pool-size=num set v8's thread pool size
–tls-cipher-list=val use an alternative default TLS cipher list
–openssl-config=path load OpenSSL configuration file from the specified path
–icu-data-dir=dir set ICU data load path to dir (overrides NODE_ICU_DATA)
–preserve-symlinks preserve symbolic links when resolving and caching modules.
–harmony harmony is a shortcut on old node to enable all the harmony features

Environment variables

Name Description
NODE_PATH ';'-separated list of directories prefixed to the module search path.
NODE_DISABLE_COLORS set to 1 to disable colors in the REPL
NODE_ICU_DATA data path for ICU (Intl object) data
NODE_NO_WARNINGS set to 1 to silence process warnings
NODE_PATH ';'-separated list of directories prefixed to the module search path
NODE_REPL_HISTORY path to the persistent REPL history file

Management

How to known if a file is run directly ?

When a file is run directly from Node.js, require.main is set to its module. That means that it is possible to determine whether a file has been run directly by testing require.main === module.

For a file foo.js, this will be:

  • true if run via node foo.js,
  • false if run by require('./foo').

Documentation / Reference