resolverjs

a simple dependency resolver for nodejs

npm install resolverjs
5 downloads in the last week
20 downloads in the last month

resolverjs

Config and lock the resolver on your app start:

var resolver = require('resolverjs');
resolver.setRoot(__dirname);
resolver.lock()

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

npm loves you