|
|
%!s(int64=4) %!d(string=hai) anos | |
|---|---|---|
| .. | ||
| node_modules | %!s(int64=4) %!d(string=hai) anos | |
| index.js | %!s(int64=4) %!d(string=hai) anos | |
| license | %!s(int64=4) %!d(string=hai) anos | |
| package.json | %!s(int64=4) %!d(string=hai) anos | |
| readme.md | %!s(int64=4) %!d(string=hai) anos | |
Find the root directory of a npm package
$ npm install --save pkg-dir
/
└── Users
└── sindresorhus
└── foo
├── package.json
└── bar
├── baz
└── example.js
// example.js
var pkgDir = require('pkg-dir');
pkgDir(__dirname).then(function (rootPath) {
console.log(rootPath);
//=> '/Users/sindresorhus/foo'
});
Returns a promise that resolves to the package root path or null.
Returns the package root path or null.
Type: string
Default: process.cwd()
Directory to start from.
MIT © Sindre Sorhus