Master Node.js CLI: Essential Command-Line Options for Faster Development

This guide reviews the most powerful Node.js command‑line options—including version checks, inline evaluation, debugging inspectors, zero‑filled buffers, and profiler processing—explaining their syntax, use cases, and examples to help developers improve productivity and security when running Node applications.

Node Underground
Node Underground
Node Underground
Master Node.js CLI: Essential Command-Line Options for Faster Development

Node.js provides a rich set of command‑line options, from built‑in debugging to V8 engine tweaks, and mastering them can boost developer productivity. Below are the “master‑level” options available in the latest Node.js releases.

Command‑line options

--version (or -v ): display the current Node.js version.

--eval (or -e ): evaluate JavaScript code from the command line.

--print (or -p ): same as --eval but also prints the result.

Example: node -p '3 + 2'

--check (or -c , enabled since v4.2.0): check the syntax of a specified file without executing it.

Example: if index.js contains console.log(new Buffer(100) , run node --check index.js to verify syntax. No error stack is shown because the script is not actually run.

--inspect[=host:port] (enabled since v6.3.0): activate the inspector on the given host and port, default 127.0.0.1:9229 .

The debugger communicates via the Chrome DevTools protocol over TCP.

--inspect-brk[=host:port] (enabled since v7.6.0): same as --inspect but pauses on the first line of user script.

--zero-fill-buffers (enabled since v6.0.0): forces newly allocated Buffer instances to be zero‑filled, preventing accidental exposure of old memory data.

Use only when needed as it adds performance overhead.

Node.js Buffer API underwent many changes in v6.0.0; see related security discussions.

--prof-process : outputs V8 profiler data.

Usage: node --prof index.js

This creates a file prefixed with isolate- in the same directory.

Process the file with node --prof-process isolate-0x...-v8.log > output.txt

The resulting file contains V8 metrics such as C++ time, JavaScript time, and per‑function timings.

The complete list of Node.js CLI options is available in the official documentation. Additional V8 and environment variable options are also supported; see the original article for more details.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

performanceCLINode.jscommand-line
Node Underground
Written by

Node Underground

No language is immortal—Node.js isn’t either—but thoughtful reflection is priceless. This underground community for Node.js enthusiasts was started by Taobao’s Front‑End Team (FED) to share our original insights and viewpoints from working with Node.js. Follow us. BTW, we’re hiring.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.