node package manager


a simple dependency resolver for nodejs


Config and lock the resolver on your app start:

var resolver = require('resolverjs');

Note that resolver automatically prefixes your require string with __dirname:

// __dirname === '/home/somebody/myapp'
var myModule = resolver.get('libs/mymodule');
// would look into /home/somebody/myapp/libs/mymodule.js

Why? Resolver allows you to easily inject modules dependencies. For example:

// running in testing environment
resolver.register('/database/users_provider', myFakeUserProvider);

The get function also has a second defaultVal parameter. If you use resolverjs on the server side, it's safe to ignore. It's meant to be hack used by fakenode.js