← Back to Node.js Course | Chapter 1: Introduction | Lesson 5 of 7

node REPL

The REPL is an interactive prompt where you type JavaScript and see the result immediately.

In this page:

  1. node REPL
Syntax
javascript
$ node
> expression

node REPL

Running node with no arguments starts the Read-Eval-Print Loop. Each expression is evaluated and its result printed. Special commands begin with a dot, such as .help, .editor and .exit, and the underscore variable holds the last result.

Note: Press Ctrl+D or type .exit to leave the REPL.

Example: node REPL

bash
$ node
> 2 + 3
5
> const name = "Ada"
undefined
> `Hello, ${name}`
'Hello, Ada'
> _
'Hello, Ada'
> .exit

⚠️ Run this in your own terminal or Node.js environment.

Related Topics
Common Mistakes
  1. Forgetting the dot before REPL commands
  2. Expecting variables to persist after exiting
  3. Pasting multi-line code without .editor mode
Chapter Summary
  • node starts the REPL
  • Results print automatically
  • _ holds the last result
  • Commands start with a dot
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.