There's an open issue for adding .noderc.js support to node's repl, but the patch hasn't been pulled in at the time of this writing.

A REPL of my own

In the meantime, I read a bit in Axel Rauschmayer's post on Executing code at the REPL's startup, as well as the aforementioned bug patch and came up with a REPL of my own.

I called it injs for interactive nodejs, after the style of ruby's irb.

You can install like so:

curl -L -s > /tmp/injs.js
chmod a+x /tmp/injs.js
sudo mv /tmp/injs.js /usr/local/bin/injs


And from the new REPL try

injs> 0.1 + 0.2
injs> .exit

You can inspect the source at

Adding clear

For convenience I like to have a clear(); method that does the equivalent of bash's clear and cmd.exe's cls.

Just put this snippet in ~/.noderc.js:

(function () {
  "use strict";
  exports.clear = function () {

Everything attached to exports will be reattached to the REPL's global context. You can call any such method like so:

injs> clear();


By AJ ONeal

If you loved this and want more like it, sign up!

Did I make your day?
Buy me a coffeeBuy me a coffee  

(you can learn about the bigger picture I'm working towards on my patreon page )