Node.js Console
Node.js comes with a virtual atmosphere which is known as REPL. REPL is the Read-Eval-Print-Loop. It is a fast and effortless way to execute an easy Node.js/JavaScript program.
To launch the REPL, open the command prompt (in Windows) or terminal and write the node as indicated downward. It will replace the prompt to > in the terminal.
You can now execute any Node.js or JavaScript expression in REPL. For example 50 + 10 will show 60 instantly in new line.
The + operator also joins strings as in browser’s JavaScript.
REPL commands
There are given below some important REPL commands.
REPL Command | Description |
---|---|
.help | Display help on all the commands |
.save filename | Save current Node REPL session to a file. |
.load filename | Load the specified file in the current Node REPL session. |
tab Keys | Display the list of all commands. |
Up/Down Keys | See previous commands applied in REPL. |
ctrl + c | Terminate the current command. |
ctrl + c (twice) | Exit from the REPL. |
ctrl + d | Exit from the REPL. |
.break | Exit from multiline expression. |
.clear | Exit from multiline expression. |