Get the first existing path on disk from a list of candidate paths, returning it in array order (or the first match if you disable order preservation). Useful in Node.js apps for resolving which of several file or directory paths actually exists, with options to filter by type (file, directory, or both) and handle symlinks.
Project status
- The repo appears actively maintained, with a recent update (v8.0.0 on 2025-09-15) following earlier releases (v7.2.0 in 2023, v7.1.1 in 2022).
- The apparent update cadence is low to moderate, with about a 2 year gap between v7.2.0 (2023-02-09) and v8.0.0 (2025-09-15).
AI summary generated Today
Recent updates
v8.0.0
8 months agov8.0.0 raises the minimum supported Node.js version to 20 and adds a new option value, `type: 'both'`, to allow matching both files and directories. Most of the functional change is implemented in the runtime type checking and stat matching logic, and tests and typings were updated accordingly.
BreakingFeaturesv7.2.0
2/9/2023Release v7.2.0 primarily includes a small performance improvement. The only functional code change in the diff is in `locatePathSync`, where the underlying `statFunction` call now suppresses errors for missing entries and the loop explicitly continues when no stat is returned.
v7.1.1
6/6/2022v7.1.1 bumps the locate-path package version and tightens validation around the `options.type` option. The change improves robustness by adjusting how `type` is validated and how the stat matcher selects the appropriate filesystem stat check.
v7.1.0
2/8/2022Release v7.1.0 adds support for passing a WHATWG URL as the `cwd` option to both `locatePath` and `locatePathSync`. The implementation converts `URL` to a filesystem path via `fileURLToPath`, and the TypeScript types, README, and tests were updated accordingly.
Featuresv7.0.0
8/25/2021This release converts locate-path to pure ESM and switches from a default export to named exports. The implementation and TypeScript typings now export two functions, locatePath (async) and locatePathSync (sync). It also updates the Node.js engine requirement and bumps p-locate plus test/lint dependencies.
Breakingv6.0.0
8/10/2020This release (v6.0.0) updates the package to require Node.js 10 and refreshes TypeScript declaration/export compatibility. The code changes are small, but the dependency set and tooling configuration were also updated.
Breakingv5.0.0
5/4/2019v5.0.0 changes the default behavior of locate-path to only match files, not both files and directories. It also introduces new options, `type` and `allowSymlinks`, to control whether paths must be files or directories and whether symlinks should be followed when determining that type.
BreakingFeaturesv4.0.0
4/15/2019v4.0.0 introduces a breaking runtime requirement by raising the minimum supported Node.js version to 8. It also adds TypeScript type definitions to improve TypeScript developer experience.
BreakingFeatures