I have a module. Inside this, I would like to access data from my parent package package.json. What is the best way to do this?
I did it in a janky way, going up 2 levels and requiring a file (or using the nconf configuration loader).
var appdir = path.resolve(__dirname, '../../');
nconf.file('app', path.join(appdir, 'package.json'));
But it looks like it could break easily.
I also heard about pkginfo , it automatically grabs information from my own package.json module, but I want to get data from the parent application.
Thanks for any help!
EDIT: I assume another way to ask the question is: how can I get the path to the program (instead of the path to the module)?
source
share