pRequire
pRequire is a small abstraction to the require
statement.
Usage
Add the following statement to your app's entry point.
__dirname
This will create a GLOBAL reference to pRequire, which allows you to require modules defined in your package.json
relative to your project root not located in node_modules
.
You then define keys in your package.json
that reference modules relative to the root folder.
package.json
Example "localDependencies":
Note: libIndex
is referencing a folder that contains index.js. It works just like require('./test/lib');
.
Example of pRequire statement
__dirname; var base = ; var libIndex = ; var libOther = ; console;
You can run node test.js
to see pRequire in action.