A helper to require module relative to project root "APP_HOME" instead of current module directory.

npm install apphome
6 downloads in the last month


It is not uncommon to require modules residing in other directories from deep inside another directory, for example,


Keeping track of relative require becomes a maintenance nightmare when we have a bunch of these and many directories.

apphome.js attempts to make relative require a little bit easier to maintain. It is a simple module that does only one thing - translate the given path relative to a known starting point.


To install the latest official version, use NPM:

npm install apphome


apphome.js uses the environment variable APP_HOME to determine the root of the project. If APP_HOME is not set, it falls back to current working directory (as reported by process.cwd()).

var apphome = require('apphome');
var moda = require(apphome('moda'));
var modc = require(apphome('moda/modb/modc'));

If you prefer to use a different environment variable, say PROJECT_HOME, then

var apphome = require('apphome');
var modc = require(apphome('moda/modb/modc', 'PROJECT_HOME'));


npm test

Note: For when Proxy is supported, it will be possible to use property access to require a module.

var apphome = require('apphome');
var modc = require(;  //ERROR maybe in the future
npm loves you