Run code
node
Start the interactive REPL
node -e "<code>"
Evaluate a string of code
node -p "<expr>"
Evaluate and print the result
node <file> <args>
Pass arguments to the script
Read them from process.argv.slice(2).
node -
Read the script from stdin
node -c <file>
Syntax check without running
node --input-type=module -e "<code>"
Evaluate code as an ES module
Allows import and top-level await in -e.
node -v
Print the Node version
corepack enable
Activate pnpm and yarn shims
Bundled with Node 20 and 22; not with Node 25+.
node -p "process.versions"
Show V8 and library versions
Test runner
node --test
Run all discovered test files
Finds *.test.js, test/**, and similar patterns.
node --test <file>
Run specific test files
node --test-name-pattern="<regex>"
Run tests whose name matches
node --test-only
Run only tests marked only
node --test-reporter=<name>
Choose output: spec, tap, dot, junit
node --test --watch
Re-run tests on change
Minimal test file
import test from 'node:test';import assert from 'node:assert/strict';test('adds', () => { assert.equal(1 + 1, 2);});
Environment and config
node --env-file=<file> <script>
Load variables from a .env file
Repeat the flag to load several files; later ones win.
NODE_OPTIONS="<flags>" node
<script>
Set default flags via environment
NODE_ENV=production node <script>
Set a variable for one run
Only a convention that libraries read; Node itself ignores it.
node --require <module>
Preload a CommonJS module
node --import <module>
Preload an ES module
node --run <script>
Run a package.json script
Node 22+. Faster than npm run but has no lifecycle hooks.
node --title=<name> <script>
Set the process title
Debugging
node --inspect <file>
Start with the inspector open
Then open chrome://inspect or attach an editor on port 9229.
node --inspect-brk <file>
Break on the first line
node inspect <file>
Use the built-in CLI debugger
node --enable-source-maps <file>
Map stack traces to source files
node --trace-warnings <file>
Show where warnings come from
node --trace-deprecation <file>
Show where deprecated APIs are used
node --no-warnings <file>
Silence all process warnings
NODE_DEBUG=<module> node <file>
Log internals, e.g. http, fs