required-from
Get absolute path to the module that required your module
Usage
Get Absolute Path of Parent Module
// project root├── indexjs├── foojs├── barjs└── bazjs
// index.js (entry point of app) const foo = // foo.js const bar = ; // bar.js const requiredFrom = ; const requireDirectory = ; console; // /absolute/path/to/foo.js
Note: It will throw an error if you try to call it from a module that is not required by a parent module during runtime.
License
MIT © Nivrith Mandayam Gomatam