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 epr with all npm packages installed. Try it out:

var epr = require("epr")

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

epr v1.0.0

A tool for making node require paths nicer

EPR travis status

epr lets you use nicer require paths in your node programs. It lets you change code like this:

var module1 = require('../../../modules/module1'),
    module2 = require('./another/path/module2')


var module1 = require('module1'),
    module2 = require('module2')

How do you install it?

npm install -g epr

How do you use it?

Add an epr key to your package.json:

  "epr": {
    "module1": "lib/modules/module1"

and run epr:


epr will create symlinks in node_modules/ for each attribute in your epr object. Normal node rules follow, so you can add a package.json file for each of your directories to point to a main, or you can just use it as a shortcut:

var module1 = require('module1'),
// or
    module2 = require('module1/module2')

to set this up for deployments, call epr in your postinstall script

Any advice?

There are several ways you can use epr, you can link to individual modules, or you can link to directories that contain several modules. In either case I'd recommend linking to directories rather than specific files in either case. That makes them easier to later split out to external packages if you want to.

So if you are linking to an individual module, at say lib/modules/mymodule, just add "mymodule":"lib/modules/mymodule". This is best if you've got some sort of code that could be an external module, but you want to keep it internal for whatever reason.

If you've got a directory that contains modules of a particular type, say a "modals" directory, you can link to that by adding "modals": "lib/modals", and can be required with something like require('modals/user')

Lastly you could just link to lib/ or wherever else you store most your code.

Does it do anything else?


  • epr clean: delete all symlinks that are not in package.json
  • epr empty: delete all symlinks in node_modules

can I use it from javascript?


var epr = require('epr')
epr.entangle(process.cwd(), {module1: 'lib/module1'}) // create symlinks
epr.clean(process.cwd(), {module1: 'lib/module1'}) // same as epr clean
epr.empty(process.cwd()) // same as epr empty

All epr api functions can either take a standard node callback or return a promise

epr.entangle(process.cwd(), {module1: 'lib/module1'}, function(err){
  if(err) {
  } else {

epr.entangle(process.cwd(), {module1: 'lib/module1'}.then(function(){
}, function(err){

I'd like to make a change

See contributing

What's with the name?

EPR is a reference to the Einstein-Podolsky-Rosen thought experiment which was the origin of the concept of entanglement in quantum mechanics, and the term "spooky action at a distance".

OS support

epr will definitely run under any unix, but it has not been tested under windows. Any testing or PRs for windows support would be greatly appreciated. It has specifically been tested to run in heroku.


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