# Node.js CLI commands and flags

*JavaScript Developer Study Guide · Server Side JavaScript · Last updated October 16, 2026 · https://www.certifyforce.com/study-guide/javascript-developer/server-side-javascript/nodejs-cli-commands-and-flags*

Which node command fits the job: --check for a syntax-only pass, -e and -p for inline code, --require and --import to preload modules, --inspect and --inspect-brk for debugging, plus how arguments reach process.argv, how process.env is read and how the REPL works.

- Certification: Salesforce JavaScript Developer
- Exam section: Server Side JavaScript
- Study guide: https://www.certifyforce.com/study-guide/javascript-developer

**Official exam objective:**

> Given a scenario and requirements, infer which Node.js CLI command is a good solution.

## What the exam expects

- Pick the `node` flag for a requirement: syntax-check without running, evaluate or print inline code, preload a module, or attach a debugger before the first line runs.
- Place options and script arguments in the right order and predict the contents of `process.argv`.
- Read configuration from environment variables with `process.env` (and `--env-file`), knowing values are strings.
- Start and use the REPL for quick experiments.

Key terms: **option** (a flag such as `--check` written before the entry script, read by Node.js); **argument** (anything after the entry script, passed to the script); **inspector** (the V8 debugging agent that tools such as Chrome DevTools attach to); **preload** (a module run at startup before the entry script); **REPL** (Read-Eval-Print Loop, the interactive `node` prompt).

## Key facts

| Fact | Detail | Source |
|---|---|---|
| Synopsis | `node [options] [V8 options] [script.js \| -e "script" \| - ] [arguments]` | [Usage and example](https://nodejs.org/api/synopsis.html) |
| `process.argv[0]`, `[1]` | `process.execPath`, then the absolute path of the entry script | [Process](https://nodejs.org/api/process.html) |
| `-c, --check` | Syntax check without executing | [Command-line API](https://nodejs.org/api/cli.html) |
| `-p, --print` | Identical to `-e` but prints the result | [Command-line API](https://nodejs.org/api/cli.html) |
| Preload order | `--require` modules run before `--import` modules | [Command-line API](https://nodejs.org/api/cli.html) |
| Inspector default | `127.0.0.1:9229` | [Debugging Node.js](https://nodejs.org/learn/getting-started/debugging) |
| `--inspect-brk` | Breaks at the start of the user script | [Command-line API](https://nodejs.org/api/cli.html) |
| `--env-file` precedence | The existing environment wins over the file | [Command-line API](https://nodejs.org/api/cli.html) |
| `process.env` values | Assigned values are converted to strings (deprecated behavior) | [Process](https://nodejs.org/api/process.html) |
| REPL `_` | Result of the most recently evaluated expression, until `_` is assigned explicitly | [REPL](https://nodejs.org/api/repl.html) |

## Check yourself

- Why does `node report.js --verbose` leave `--verbose` for the script instead of Node.js?
- When should you choose `--inspect-brk` over `--inspect`?
- Which flag preloads a CommonJS module before the entry script?
- What type is `process.env.PORT` when set to 8080?

## Sources

- [Command-line API](https://nodejs.org/api/cli.html)
- [Usage and example](https://nodejs.org/api/synopsis.html)
- [Process](https://nodejs.org/api/process.html)
- [Debugging Node.js](https://nodejs.org/learn/getting-started/debugging)
- [Run Node.js scripts from the command line](https://nodejs.org/learn/command-line/run-nodejs-scripts-from-the-command-line)
- [How to read environment variables from Node.js](https://nodejs.org/learn/command-line/how-to-read-environment-variables-from-nodejs)
- [How to use the Node.js REPL](https://nodejs.org/learn/command-line/how-to-use-the-nodejs-repl)
- [REPL](https://nodejs.org/api/repl.html)
- [Debugger](https://nodejs.org/api/debugger.html)

## About the full unit

The "Core concepts", "Exam traps" and "Worked scenario" sections of this unit, its 5 linked practice questions, and unlimited timed mock exams are included with the JavaScript Developer pack (USD $19): https://www.certifyforce.com/practice-exams
