Node - Node Cli

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





Discover More
Global Namespace Web Console Firefox
Browser - (Window | Tab) (Javascript Global scope)

window: is a javascript object that represents a tab in the whole browser that render a document. is the javascript global scope for the variable in the browser. is part of the web api holds the...
CommonJs (NodeJs) - Require

The import functionality implementation of commonjs (and then node) is done via the require function require basically: reads a Javascript file (generally a CommonJs module but it may be any javascript...
Javascript - CommonJs

CommonJs is a Module format definition They have defined: * a Module * and packages definition The CommonJS...
Node - script (Javascript)

in the node engine. Javascript file are generally in the src, lib, or dist directory commander To run the below script with the node engine: At the command line Runkit Playground:...
Node API

The node API is the API (collection of package and method) implemented by the Node engine. This is a server API meaning that it adds: File System operation process operation and more



Share this page:
Follow us:
Task Runner