</>
Skip to content
Node.js lessons (5/44)

Node.js — REPL

What is REPL?

REPL stands for Read-Eval-Print Loop — an interactive JavaScript shell.

node

Basic Usage

> 1 + 1
2

> 'Hello' + ' World'
'Hello World'

> const x = 10
undefined

> x * 2
20

REPL Commands

CommandDescription
.helpShow help
.exitExit REPL
.clearClear context
.save fileSave to file
.load fileLoad file

Working with Modules

> const fs = require('fs')
undefined

> fs.readdirSync('.')
['file1.js', 'file2.js']

Multi-line Input

> function add(a, b) {
...   return a + b;
... }
undefined

> add(2, 3)
5

Underscore Variable

> 1 + 1
2

> _ + 10
12

REPL Tips

  1. Use Tab for autocompletion
  2. Use ↑/↓ for command history
  3. Use Ctrl+C to cancel
  4. Use Ctrl+D to exit

Mini Practice

  1. Start the REPL
  2. Do some math
  3. Require a module
  4. Save REPL session to file

Up Next

Continue with Command Line — Node.js CLI tools.

Related Topics

Frequently Asked Questions about REPL

What is REPL in Node.js?

REPL is a fundamental concept in Node.js. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn REPL?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn REPL.

Why is REPL important in Node.js?

REPL is essential for Node.js development. Understanding this concept will help you write better code and solve real-world problems more effectively.