module_path
v1.0.2
Published
Kind of basic, but get the absolute path to your module
Downloads
3
Readme
module_path
Kind of basic, but get the absolute path to your module
// the folder your source file is in
console.log(require('module_path')(module));
// the folder above your source folder
console.log(require('module_path').parent_path(module));
//the folder 2 above your source folder
console.log(require('module_path').parent_path(module,-2));
// the folder called src under the folder your source file is in
console.log(require('module_path')(module,'src'));
// the folder called html/images adjacent to the folder your source file is in
console.log(require('module_path').parent_path(module,-1,'html/images'));
real world use example
var myLibFunc = require(require('module_path').parent_path(module,-1,'lib/myLib.js')).myLibFunc;