Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

requerem

orouji15MIT0.3.0

a "require" replacement that prevents require('../../../../foo') thing when working with multiple modules in nodejs apps.

require, requerem, multi module node app, app-root, app-root-path

readme

requerem

a "require" replacement that prevents require('../../../../foo') thing when working with multiple modules in nodejs apps.

Installation

   npm install requerem --save

Usage

In top of your main js script (app.js) add:

   require('requerem'); // it adds your app-root to module resolver path

now you can simply require your app-specific modules relative to your project root:

   var User = require('models/User'); // app-specific module (relative to project root)

and requiring npm-installed modules stays the same as before:

   var mongoose = require('mongoose'); // installed modules

also relative paths:

   var config = require('./config');

Tests

npm test