# path-exists

> Check if a path exists

Latest version **5.0.0** (published 2021-08-12) · MIT license · 0 weekly downloads

> **Better alternative:** See documentation for alternatives (https://github.com/AikidoSec/module-replacements/blob/main/docs/path-exists)

## Install

```sh
npm install path-exists
pnpm add path-exists
yarn add path-exists
bun add path-exists
```

## Health

**Score 28/100 (F)** — status: abandoned.

Positive: has types package; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2021-08-12 |
| First published | 2015-05-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/path-exists) |
| Module format | ESM |
| Node | ^12.20.0 \|\| ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 0 |
| Unpacked size | 4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 156 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | path, exists, exist, file, filepath, fs, filesystem, file-system, access, stat |

## Links

- npm: https://www.npmjs.com/package/path-exists
- Repository: https://github.com/sindresorhus/path-exists
- Homepage: https://github.com/sindresorhus/path-exists#readme
- Issues: https://github.com/sindresorhus/path-exists/issues
- npm.io page: https://npm.io/package/path-exists

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 5.0.0 (latest) — 2021-08-12
- 4.0.0 — 2019-04-04
- 3.0.0 — 2016-05-01
- 2.1.0 — 2015-11-14
- 2.0.0 — 2015-09-01
- 1.0.0 — 2015-05-02

## README

# path-exists

> Check if a path exists

NOTE: `fs.existsSync` has been un-deprecated in Node.js since 6.8.0. If you only need to check synchronously, this module is not needed.

Never use this before handling a file though:

> In particular, checking if a file exists before opening it is an anti-pattern that leaves you vulnerable to race conditions: another process may remove the file between the calls to `fs.exists()` and `fs.open()`. Just open the file and handle the error when it's not there.

## Install

```
$ npm install path-exists
```

## Usage

```js
// foo.js
import {pathExists} from 'path-exists';

console.log(await pathExists('foo.js'));
//=> true
```

## API

### pathExists(path)

Returns a `Promise<boolean>` of whether the path exists.

### pathExistsSync(path)

Returns a `boolean` of whether the path exists.

## Related

- [path-exists-cli](https://github.com/sindresorhus/path-exists-cli) - CLI for this module
- [path-type](https://github.com/sindresorhus/path-type) - Check if a path exists and whether it's a file, directory, or symlink

---

<div align="center">
	<b>
		<a href="https://tidelift.com/subscription/pkg/npm-path-exists?utm_source=npm-path-exists&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
	</b>
	<br>
	<sub>
		Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
	</sub>
</div>

---
_Source: https://npm.io/package/path-exists · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
