Easier node require

Instead of doing this

var http = require('http'),
    myModule = require('./lib/myModule'),
    User = require('./lib/models').User;
// rest of your code 

you do

require("them")(function(httpmyModuleUser) {
  // rest of you code 
  • Avoid redundand pattern of require
  • Have centralized, relative to the root require
  • Contistent naming across my application
  • Configurable require for test and coverage
  • Stop the "where the comma should go" debate
  • Do not use in libraries or modules, but you can safely use it in your application.
  • This library is quite young, please be careful and patient.
npm install them --save

You must initialize them before you use it, because you have to tell what is your root module and all the required modules should be relative to that.

require('them').init(module, [mapping]);
  • module: do not change it, you have to pass the module
  • mapping: a simple which contains mapping between name and module if it doesn't match.


require('them').init(module, {
    _: "underscore",
    email: "./services/email",
    User: "./models/models#User",


require("them")(function(http_emailUser) {
  // you code 
  • Automatically require module based on the parameter name
  • You have to configure manually your own submodules to be requirable, by default it search from the ./lib/ directory
  • You can change the default library directory with THEM_LIB environment variable. It's useful for coverage