Back to Explore

sindresorhus/locate-path

GitHub
1 watchersOpen source

Last release: 8 months ago

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

AI-generated from public sources. May be inaccurate. Report

Recent updates

  • v8.0.0

    8 months ago

    v8.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.

    BreakingFeatures
  • v7.2.0

    2/9/2023

    Release 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/2022

    v7.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/2022

    Release 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.

    Features
  • v7.0.0

    8/25/2021

    This 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.

    Breaking
  • v6.0.0

    8/10/2020

    This 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.

    Breaking
  • v5.0.0

    5/4/2019

    v5.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.

    BreakingFeatures
  • v4.0.0

    4/15/2019

    v4.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