Author Profile Altaf Shaikh
Altaf Shaikh

BE Engg | Python Dev | Content Writer | Founder of TeachMeBro | Blockchain Dev | Django

Node.js - REPL Terminal

January 24th 2021   365

Node.js - REPL Terminal
Node.js - REPL Terminal

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 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 <your-operating-system>".

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.