Node.js CLI/Print expression result

Evaluate an expression and print its result.

Section: Basics and Invocation

Print expression result

bash
bash
node -p "process.platform + ' ' + process.arch"
Explanation

`-p` is useful in scripts where you want the value printed automatically.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Basics and Invocation
Print Node version
Show the current Node.js version.
OpenIn sheetbashsame section
Show CLI help
Print built-in CLI help.
OpenIn sheetbashsame section
Print V8 options
List V8 engine flags.
OpenIn sheetbashsame section
Run a script file
Execute a JavaScript entry file.
OpenIn sheetbashsame section
Execute inline JavaScript
Run a one-liner directly from the shell.
OpenIn sheetbashsame section
Run script from stdin
Feed JavaScript to Node from standard input.
OpenIn sheetbashsame section