module_path

1.0.2 • Public • Published

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;

Readme

Keywords

none

Package Sidebar

Install

npm i module_path

Weekly Downloads

1

Version

1.0.2

License

none

Last publish

Collaborators

  • sophtwhere