Home » Node.js Command Line Options

Node.js Command Line Options

by Online Tutorials Library

Node.js Command Line Options

There is a wide variety of command line options in Node.js. These options provide multiple ways to execute scripts and other helpful run-time options.

Let’s see the list of Node.js command line options:

Index Option Description
1. v, –version It is used to print node’s version.
2. -h, –help It is used to print node command line options.
3. -e, –eval “script” It evaluates the following argument as JavaScript. The modules which are predefined in the REPL can also be used in script.
4. -p, –print “script” It is identical to -e but prints the result.
5. -c, –check Syntax check the script without executing.
6. -i, –interactive It opens the REPL even if stdin does not appear to be a terminal.
7. -r, –require module It is used to preload the specified module at startup. It follows require()’s module resolution rules. Module may be either a path to a file, or a node module name.
8. –no-deprecation Silence deprecation warnings.
9. –trace-deprecation It is used to print stack traces for deprecations.
10. –throw-deprecation It throws errors for deprecations.
11. –no-warnings It silence all process warnings (including deprecations).
12. –trace-warnings It prints stack traces for process warnings (including deprecations).
13. –trace-sync-io It prints a stack trace whenever synchronous i/o is detected after the first turn of the event loop.
14. –zero-fill-buffers Automatically zero-fills all newly allocated buffer and slowbuffer instances.
15. –track-heap-objects It tracks heap object allocations for heap snapshots.
16. –prof-process It processes V8 profiler output generated using the v8 option –prof.
17. –V8-options It prints V8 command line options.
18. –tls-cipher-list=list It specifies an alternative default tls cipher list. (requires node.js to be built with crypto support. (default))
19. –enable-fips It enables fips-compliant crypto at startup. (requires node.js to be built with ./configure –openssl-fips)
20. –force-fips It forces fips-compliant crypto on startup. (cannot be disabled from script code.) (same requirements as –enable-fips)
21. –icu-data-dir=file It specifies ICU data load path. (Overrides node_icu_data)

Node.js Command Line Options Examples

To see the version of the running Node:

Open Node.js command prompt and run command node -v or node –version

Node.js Command Line Options 1

For Help:

Use command node ?h or node –help

Node.js Command Line Options 2

To evaluate an argument (but not print result):

Use command node -e, –eval “script”

To evaluate an argument and print result also:

Use command node -p “script”

Node.js Command Line Options 3

To open REPL even if stdin doesn’t appear:

Use command node -i, or node –interactive

Node.js Command Line Options 4

You may also like