Using Node.js REPL Terminal
node command is the one we use to run our
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 ".
Start simple and enter
> console.log('test') test undefined >
The first value, test, is the output we told the console to print, then we get undefined which is the return value of running
- 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.