node package manager



Create your REPL by slotting REPL files and functionality into your import folder.


Firstly install the module via npm:

npm install repl8

Then require it into your application:

var repl8 = require('repl8');

We simply call the .start function and pass it in an options object:

  src: __dirname + '/import', // This is required to tell repl8 where to load in our logic
  ignoreUndefined: true, 
  prompt: 'repl8> '

The options object takes the same options as the original nodejs .repl function, with the addition of the src option which points to where we will import our REPL commands.

Writing Commands

Create a file in your import folder with the name of your command. In this example, we will create one called loop.js

This will immediately give our repl the command loop.

Now inside loop.js, lets make give it some functionality.

module.exports = function (max) {
  for (i = 0; i < max; i++)
    console.log("woo " + i);

Now restart our REPL and call our new loop function:

repl8> loop(3)
woo 0
woo 1
woo 2