The Node.js REPL is very useful for dealing with node.js and debugging JavaScript code and works similar to Google Chrome’s REPL, in order to know the current command list Press "
Tab key" so the list of commands get displayed as shown in the image below.
Following are few important commands of REPL.
.break -
The command can be used in situations like to stop or start over again. Using "
.break" it is easy to terminate from multi-line expressions as shown below.
.save -
The REPL can be saved using the "
.save" command to a file, write the command with a file name as shown in the image below.
. help -
All the REPL options or commands can be displayed using this command, the list of REPL commands can be seen as shown below.
.load -
The command used to load the JS from a file into the REPL session, the image below demonstrate loading a file called main.js into REPL session.
Main.js
[c]
var x =0;
do
{
x++;
console.log("The value of x is : " +x);
}
while (x!=5);
[/c]
The above file can be loaded into REPL session by using
.load command as shown in the image below.
.clear -
The "
.clear" command is the alias for "
.break" command, the clear command is used to clear the multi-line expressions as shown in the image below.
ctrl + c twice
To exit the REPL click the this key combination i.e "
ctrl + c twice".