Returns the package root path of the specified filename. If no filename is given, will return the package root of the current file. The module root is where the closest package.json is found.

packageRoot(filepath)

Examples

packageRoot(); 
// /home/tim/projects/firost

packageRoot('~/projects/aberlaas/lib/main.js'); 
// /home/tim/projects/aberlaas/