Using Node.js REPL Terminal

Using Node.js REPL Terminal

Subscribe to my newsletter and never miss my upcoming articles

Listen to this article

The node command is the one we use to run our Node.js scripts:

node script.js

If we omit the filename, we use it in REPL (Read Evaluate Print Loop) mode:


Note: REPL also known as Read Evaluate Print Loop is a programming language environment(Basically a console window) that takes single expression as user input and returns the result back to the console after execution.

If you try it now in your terminal, this is what happens:

❯ node


the command stays in idle mode and waits for us to enter something.

Tip: if you are unsure how to open your terminal, google "How to open terminal on ".

The REPL is waiting for us to enter some JavaScript code, to be more precise.

Start simple and enter

> console.log('test')




The first value, test, is the output we told the console to print, then we get undefined which is the return value of running console.log().

We can now enter a new line of JavaScript.

REPL Commands

  • ctrl + c - terminate the current command.
  • ctrl + c twice - terminate the Node REPL.
  • ctrl + d - terminate the Node REPL.
  • Up/Down Keys - see command history and modify previous commands.
  • tab Keys - list of current commands.
  • .help - list of all commands.
  • .break - exit from multiline expression.
  • .clear - exit from multiline expression.
  • .save filename - save the current Node REPL session to a file.
  • .load filename - load file content in current Node REPL session.

So in this section, we saw the usage of Node REPL to execute Javascript code.

Share this