Skip to Content
APIexists

exists

Check if a path exists (file, directory, or symlink). Returns a boolean; does not distinguish type. Prefer stat if you need metadata.

Basic usage

import { exists } from '@vooya/fs' const ok = await exists('./package.json') if (ok) await doSomething()

Methods

exists(path)

Async. Returns Promise<boolean>. This is a Vooya FS convenience API; Node does not expose fs.promises.exists.

ArgumentTypeDescription
pathstringPath to check.

existsSync(path)

Sync. Returns boolean.

Performance

From repo benchmarks (pnpm build && pnpm bench):

ScenarioNode.jsVooya FSNote
existsSync (existing file)444 ns1.34 µsNode.js internal fast path

For sync “exists” checks on hot paths, Node.js can be faster; for async or batch use Vooya FS is fine.

Notes

  • Race: Between exists() and a subsequent operation the file may be deleted; prefer stat or try the operation and handle ENOENT when robustness matters.
  • Type: Use stat/lstat if you need to know whether the path is a file, directory, or symlink.
  • Symlinks: Broken symlinks return false, matching node:fs.existsSync.
  • Unsupported Node path inputs: Buffer paths and URL paths are not part of the current Vooya FS exists surface.

Competitor measurements

See the full exists comparison table for Node 22/24, peer libraries, sync/Promise modes, small and batch workloads, execution routes and measurement limits.

Last updated on