node package manager
Easy collaboration. Discover, share, and reuse code in your team. Create a free org ยป



If you're familiar with node.js then you're familiar with the provided REPL. You can embed a REPL in your programs and make it available via tcp or unix sockets so that you can connect to a long running node.js program and play around with it on a command line. Webrepl takes the same idea but makes the repl available via an interactive web page so that you can have all the fun of using a repl right in your web browser.

  • Node.js repl for your process in your browser
  • Tab completion is included!
  • Command history via up and down arrows
  • Webrepl also makes the properties in your context accessible via restful http calls.
  • UI inspired by
  • Optional http authentication

See a Screenshot

Requires: Node v0.4.0 or higher, but may work on older versions. I haven't tested this yet.


npm install webrepl

Or just dump all the files into your project's directory. Node module http-digest required for auth. This will be fetched by npm, but you will have to fetch it yourself if you're not using npm and want auth.


var webrepl = require('webrepl');

Then point your browser to http://localhost:8080 and have fun!

You can provide context variables just like the regular repl:

var webrepl = require('webrepl');
var foo = { 'bar': 1, 'day': new Date() };
webrepl.start(8080) = foo;

HTTP Authentication can be set (uses http digest authentication):

var webrepl = require('webrepl');
var options = { 'username': 'user', 'password': 'password' };
webrepl.start(8080, options);

Available options:

var options = {
   'username': 'username for http authentication, password must also be set',
   'password': 'password for http authentication, username must also be set',
   'hostname': 'hostname to listen on. ex: localhost,, etc'

You can also access context variables via HTTP, for example:

~ mmattozzi$ curl -i "http://localhost:8080/context/foo"
HTTP/1.1 200 OK
Content-Type: application/json
Connection: keep-alive
Transfer-Encoding: chunked


~ mmattozzi$ curl -i "http://localhost:8080/context/"
HTTP/1.1 200 OK
Content-Type: application/json
Connection: keep-alive
Transfer-Encoding: chunked


Usage Note

If you try to start webrepl from the normal, command line repl without assigning it to a variable, you'll see some exceptions. This isn't a problem with starting the server, it's only a problem with parsing the REPLServer object that gets returned.

Here we see an exception because node's object inspection can't output the standard REPLServer object that gets returned:

> require('webrepl').start(8080);
TypeError: Cannot convert object to primitive value
    at String.STRING_ADD_LEFT (native)
    at isRegExp (util.js:266:14)
    at format (util.js:163:11)
    at util.js:195:19
    at (native)
    at format (util.js:172:23)
    at util.js:195:19
    at (native)
    at format (util.js:172:23)
    at util.js:195:19

Here there's no exception because the object is assigned to a variable:

> var wr = require('webrepl').start(8080);

In both cases, webrepl started successfully and is running!

Security Note

Webrepl can be used to do all sorts of harm to the host system using the require keyword. Think twice, then a few more times before exposing webrepl to the world. Optional auth can be used to prevent unwanted access, but the connection is still insecure/unencrypted.