Gathering detailed insights and metrics for resolve-package-path
Gathering detailed insights and metrics for resolve-package-path
Gathering detailed insights and metrics for resolve-package-path
Gathering detailed insights and metrics for resolve-package-path
resolve-global
Resolve the path of a globally installed module
find-up
Find a file or directory by walking up parent directories
global-modules
The directory used by npm for globally installed npm modules.
module-details-from-path
Resolve npm package details, like name and base path, given an absolute path to a file inside a package
a special purpose fast memoizing way to resolve a node modules package.json
npm install resolve-package-path
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.2
Supply Chain
93.9
Quality
77.8
Maintenance
100
Vulnerability
100
License
TypeScript (97.71%)
JavaScript (2.29%)
Total Downloads
203,193,427
Last Day
71,324
Last Week
1,233,611
Last Month
5,686,235
Last Year
60,598,744
MIT License
32 Stars
159 Commits
10 Forks
4 Watchers
7 Branches
9 Contributors
Updated on Mar 21, 2025
Minified
Minified + Gzipped
Latest Version
4.0.3
Package Id
resolve-package-path@4.0.3
Size
14.96 kB
NPM Version
6.14.8
Node Version
12.19.0
Published on
Sep 13, 2021
Cumulative downloads
Total Downloads
Last Day
-26.5%
71,324
Compared to previous day
Last Week
-15.7%
1,233,611
Compared to previous week
Last Month
2.5%
5,686,235
Compared to previous month
Last Year
10.4%
60,598,744
Compared to previous year
1
This project is special-purpose, made to resolve package.json
files for:
It cannot and does not resolve anything else.
To achieve its file-resolution performance, it does two specific things:
It memoizes results identically to node's require
. Specifically,
for a given moduleName and baseDir it will, for the duration of the process,
always return the exact same response.
It re-implements the parts of require.resolve
needed to resolve package.json
files ONLY. This removes unneeded I/O. (based on @davecombs approach)
1yarn add resolve-package-path
1const resolvePackagePath = require('resolve-package-path');
2
3resolvePackagePath('rsvp', 'base-dir/to/start/the/node_resolution-algorithm-from') // => /path/to/rsvp.json or null
4
5const { findUpPackagePath } = resolvePackagePath;
6findUpPackagePath('base-dir/to/start') // => path/to/package.json or null
Node supports --preserve-symlinks
and NODE_PRESERVE_SYMLINKS=1
for compatibility this library respects these.
Although by default resolve-package-path
caches or memoizes results, this feature can be disabled:
1const resolvePackagePath = require('resolve-package-path');
2
3resolvePackagePath('rsvp', 'base-dir/to/start/the/node_resolution-algorithm-from', false) // => uncached result /path/to/rsvp.json or null
4
5const { findUpPackagePath } = resolvePackagePath;
6findUpPackagePath('base-dir/to/start', false) // => path/to/package.json or null
1const resolvePackagePath = require('resolve-package-path'); 2resolvePackagePath._resetCache();
In some advanced circumtances, you may want to gain access to the cache to share between more systems. In that case, a cache instance of the following form can be provided as a third argument:
1cache = {
2 RESOLVED_PACKAGE_PATH: new Map(),
3 REAL_FILE_PATH: new Map(),
4 REAL_DIRECTORY_PATH: new Map(),
5};
6findUpCache = new Map();
7
8const resolvePackagePath = require('resolve-package-path');
9resolvePackagePath('rsvp', 'path/to/start/from', cache);
10
11const { findUpPackagePath } = resolvePackagePath;
12findUpPackagePath('base-dir/to/start', findUpCache) // => path/to/package.json or null
For consumers who also do getRealFilePath
or
getRealDirectoryPath
calls on relevant paths, we expose them as utilities.
These utilties ensure identical functionality to resolve-package-path, and a
shared cache, which may help reduce IO.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
Found 2/15 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
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
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
14 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