Run files and inspect the REPL
Node can run a saved script or an interactive REPL. REPL stands for read, evaluate, print, loop. It reads an expression, evaluates it, shows a result and waits for more input. Use it for small experiments; put reproducible programs in files.
Local practice: The proposed teaching runtime is Node.js 26.13.1 LTS. These original offline examples were executed on Node.js 22.16.0 (Linux x64); execution on the proposed baseline and in ByteMind is not yet verified. No npm dependencies are required. Use a fresh practice directory. Code blocks are static, not a browser-based Node runner.
Run a saved expression with explicit output
In the directory containing the files above, run:
node main.mjsExpected standard output:
42Expected exit status: 0.
How it works
Entering node without a script in an interactive terminal opens the REPL. Type 6 * 7 and press Enter; the displayed value is 42. Exit using .exit. The REPL transcript is a manual walkthrough; terminal prompts are not JavaScript source. In a saved file, a bare expression such as 6 * 7; is evaluated but its value is not automatically printed. Use console.log() for explicit output. The CLI --print option evaluates a small expression and prints the result; use only code you wrote or reviewed.
Run a file with no explicit output
In the directory containing the files above, run:
node main.mjsExpected standard output: none.
Expected exit status: 0.
Common mistake
An expression returning a value is different from writing that value to standard output. A script containing only a calculation may exit successfully with nothing visible. Do not copy the REPL prompt (>) into source files.
Try it yourself
Evaluate 12 + 9 in the REPL if available, then save the expression alone in a file and run it. Add console.log(12 + 9) and compare. Explain why the saved expression is silent until you print it.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Run files and inspect the REPL — knowledge check
Check your understanding of run files and inspect the repl.
What does the REPL normally do with an entered expression?
What does a file containing only `6 * 7;` print?
Which is easier to rerun and share reproducibly?