parent-module alternatives and similar modules
Based on the "Miscellaneous" category.
Alternatively, view parent-module alternatives based on common mentions on social networks and blogs.
-
cheerio
Fast, flexible, and lean implementation of core jQuery designed specifically for the server. -
nan
A header file filled with macro and utility goodness for making add-on development for across Node.js versions easier. -
schemapack
Create a schema object to encode/decode your JSON in to a compact byte buffer with no overhead. -
node-video-lib
Pure JavaScript library for working with MP4 and FLV video files and creating MPEG-TS chunks for HLS streaming.
Get performance insights in less than 4 minutes
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest. Visit our partner's website for more details.
Do you think we are missing an alternative of parent-module or a related project?
README
parent-module 
Get the path of the parent module
Node.js exposes module.parent
, but it only gives you the first cached parent, which is not necessarily the actual parent.
Install
$ npm install parent-module
Usage
// bar.js
const parentModule = require('parent-module');
module.exports = () => {
console.log(parentModule());
//=> '/Users/sindresorhus/dev/unicorn/foo.js'
};
// foo.js
const bar = require('./bar');
bar();
API
parentModule(filePath?)
By default, it will return the path of the immediate parent.
filePath
Type: string
Default: __filename
File path of the module of which to get the parent path.
Useful if you want it to work multiple module levels down.
Tip
Combine it with read-pkg-up
to read the package.json of the parent module.
const path = require('path');
const readPkgUp = require('read-pkg-up');
const parentModule = require('parent-module');
console.log(readPkgUp.sync({cwd: path.dirname(parentModule())}).pkg);
//=> {name: 'chalk', version: '1.0.0', …}
Get professional support for this package with a Tidelift subscription Tidelift helps make open source sustainable for maintainers while giving companiesassurances about security, maintenance, and licensing for their dependencies.