Nodejs REPL

Nodejs comes with a REPL environment. REPL stands for read, eval, print and loop, it’s an interactive environment where users can input the details and the system will print the output in console.

  • Read – reads user input
  • Eval – after reading it will evaluate the date
  • Print – Print the result
  • Loop – continues or repeats the above process until exited

Getting used to REPL, to start the interactive mode type node and enter.


Below screenshot shows the output or REPL env.

repl output

Using REPL env with simple maths.


Below Screenshot shows the output of this program.

repl output

Using REPL with variables:

var a=10
b =10

Below screenshot shows the output for this program.

node repl output

Other commands used in REPL:
Ctrl+c – to terminate the current command
Ctrl + c c – to terminate / disconnect from REPL env.
Crtl + d – to exit / disconnect from REPL env.
up/down arrow keys – to check the command history.

Subscribe Now