Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including n_ with all npm packages installed. Try it out:

var n = require("n_")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

n_ v1.4.4

lodash REPL


Node.js REPL with lodash

Build Status Coverage Status Dependency Status npm version

animated gif showing usage of n_


Sometimes we use the Node.js REPL interface to experiment with code. Wouldn’t it be great to have that interface with lodash required by default?


$ npm install -g n_


$ n_
n_ >

lodash is now attached to the REPL context as _, so just use it:

n_ > _.compact([0, 1, false, 2, '', 3]);
[ 1, 2, 3 ]
n_ >

FP mode

It is possible to use lodash’s functional programming variant lodash/fp:

$ n_ --fp
n_ > { return v * 2; }, [1, 2, 3]);
[ 2, 4, 6 ]
n_ >

Strict mode

It is possible to enable strict mode in Node.js >= 4.x:

$ n_ --use_strict
n_ >

Or alternatively:

$ NODE_REPL_MODE=strict n_
n_ >

Using a different lodash version

n_ additionally includes all major versions of lodash starting with lodash@^3.10.1 selectable via n_<major version number>:

$ n_3
n_ > _.pluck
[Function: pluck]
n_ >

If lodash has made another major jump and I didn’t notice, give me a heads-up.


Special character _

node < 6.x

The _ character is special in the Node REPL (see

In node versions < 6.x n_ redirects this special variable to $ per default, but you can set your own using the environment variable SPECIAL_VAR like this:

$ SPECIAL_VAR=my_var n_
n_ > 123
n_ > my_var
n_ >

Also note that in node < 6.x using the command .clear you clear the context lodash is bound to.

node >= 6.x

The behavior of assigning _ to the last evaluated expression is disabled, since lodash is already assigned to _.

History persistence

n_ stores its session history under ~/.n_repl_history.



RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free