reqroot
requiring a module path resolved from application root dir
Use in global
Define require('reqroot')
in the file run directly from Node.js.
For test, use mocha -r --require
argument as mocha -r reqroot
.
Example
app.js
app.js is called by node for example node app.js
.
; const arrayUtil = ;const Book = ; Book; Book;
models/book.js
reqroot can be used directly in relative modules because global.reqroot is defined at the time required in app.js.
const arrayUtil = ; const books = name: 'A boy' name: 'Ito' ; exports { return Promise;} exports { return Promise;}
Use in a module
any sub modules, not run file
const reqroot = ; const arrayUtil = ...