use-root-path
Enables root-based require statements in node.js.
This module is based on fabmos' wonderful node.js helper named rootpath. This version is just a tiny bit cleaner to use, slightly more descriptive, and involves less code behind the scenes. Like the original, this version works with your existing local and global modules. All props to fabmos!
Install
npm install use-root-path
Usage
require( 'use-root-path' );
Examples
Before (the usual relative local paths in node.js)
var lib = require( './app/lib/library' );var util = require( '../../app/utilities/util' );var test = require( '../../app/unit-tests/test' );var morgan = require( 'morgan' );var express = require( 'express' );
After (root-based local paths in node.js)
require( 'use-root-path' ); var lib = require( 'app/lib/library' );var util = require( 'app/utilities/util' );var test = require( 'app/unit-tests/test' );var morgan = require( 'morgan' );var express = require( 'express' );
Notes
Place require( 'use-root-path' );
at the top of any module that you want to use root-based require statements. This is completely friendly with global modules too, as shown in the examples above.
Version
0.1.0 Initial Release
License
MIT