Gathering detailed insights and metrics for find-pkg-dir
Gathering detailed insights and metrics for find-pkg-dir
Gathering detailed insights and metrics for find-pkg-dir
Gathering detailed insights and metrics for find-pkg-dir
pkg-dir
Find the root directory of a Node.js project or npm package
@visulima/package
One Package to rule them all, finds your root-dir, monorepo, or package manager.
top-pkg-dir
Find top most root directory of a Node.js project or npm package.
root-pkg-dir
Find the highest directory with a package.json, starting from from the current working directory.
Find the root directory of a Node.js project from a given path
npm install find-pkg-dir
Typescript
Module System
Node Version
NPM Version
72.8
Supply Chain
89.7
Quality
75
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
314,364
Last Day
68
Last Week
922
Last Month
3,294
Last Year
29,438
ISC License
3 Stars
19 Commits
1 Forks
1 Watchers
1 Branches
1 Contributors
Updated on Jul 01, 2024
Minified
Minified + Gzipped
Latest Version
2.0.0
Package Id
find-pkg-dir@2.0.0
Size
2.42 kB
NPM Version
6.9.0
Node Version
12.3.1
Published on
May 31, 2019
Cumulative downloads
Total Downloads
Last Day
195.7%
68
Compared to previous day
Last Week
17%
922
Compared to previous week
Last Month
-20.6%
3,294
Compared to previous month
Last Year
-40.6%
29,438
Compared to previous year
1
Find the root directory of a Node.js project from a given path
1const findPkgDir = require('find-pkg-dir'); 2 3// When the /Users/shinnn/foo directory contains a package.json file: 4 5findPkgDir('/Users/shinnn/foo'); //=> '/Users/shinnn/foo' 6findPkgDir('/Users/shinnn/foo/bar'); //=> '/Users/shinnn/foo' 7findPkgDir('/Users/shinnn/foo/bar/baz'); //=> '/Users/shinnn/foo'
InternalModuleStat
through require.resolve()
as it's faster than fs.statSync()
.package.json
directory as a package.json
file.npm install find-pkg-dir
1const findPkgDir = require('find-pkg-dir');
path: string
(a path to start searching from)
Return: string
(absolute path) or null
It finds the first directory containing a package.json
file, recursively looking up, starting with the given path.
When it cannot find any package.json
files finally, returns null
.
1findPkgDir('path/of/non/nodejs/project'); //=> null
find-pkg-dir (this project):
Find from the current directory 6.514971999917179 ms/op avg.
Find from the deep directory 301.970978999976069 ms/op avg.
Resolve symlinks 4.765490400046110 ms/op avg.
Find from the `package.json` directory 33.653173299971968 ms/op avg.
find-pkg + path.dirname():
Find from the current directory 7.597467000037431 ms/op avg.
Find from the deep directory 421.827792199980479 ms/op avg.
Resolve symlinks N/A (operation failed)
Find from the `package.json` directory N/A (operation failed)
find-root:
Find from the current directory 8.991230100020767 ms/op avg.
Find from the deep directory 479.851285400055360 ms/op avg.
Resolve symlinks N/A (operation failed)
Find from the `package.json` directory N/A (operation failed)
pkg-dir:
Find from the current directory 9.322520200069993 ms/op avg.
Find from the deep directory 505.923578500002634 ms/op avg.
Resolve symlinks N/A (operation failed)
Find from the `package.json` directory N/A (operation failed)
ISC License © 2018 - 2019 Shinnosuke Watanabe
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/19 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
30 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More