# exists-file

> Check if a file exists. A fs.exists implementation that is not deprecated.

Latest version **3.0.2** (published 2017-07-18) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

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

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2017-07-18 |
| First published | 2015-06-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 4 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Kiko Beats |
| Maintainers | kikobeats |
| Keywords | directory, exists, file, file system, filesystem, fs, recursive |

## Links

- npm: https://www.npmjs.com/package/exists-file
- Repository: https://github.com/kikobeats/exists-file
- Homepage: https://github.com/Kikobeats/exists-file
- Issues: https://github.com/Kikobeats/exists-file/issues
- npm.io page: https://npm.io/package/exists-file

## Dependencies (1)

- [cb2promise](https://npm.io/package/cb2promise.md) ~1.1.0

## 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

- 3.0.2 (latest) — 2017-07-18
- 3.0.1 — 2017-04-27
- 3.0.0 — 2016-10-09
- 2.1.0 — 2016-06-28
- 2.0.2 — 2016-06-15
- 2.0.1 — 2016-06-15
- 2.0.0 — 2016-05-03
- 1.0.2 — 2016-05-03
- 1.0.1 — 2016-04-17
- 1.0.0 — 2015-06-16

## README

# exists-file

![Last version](https://img.shields.io/github/tag/Kikobeats/exists-file.svg?style=flat-square)
[![Build Status](http://img.shields.io/travis/Kikobeats/exists-file/master.svg?style=flat-square)](https://travis-ci.org/Kikobeats/exists-file)
[![Coverage Status](https://img.shields.io/coveralls/Kikobeats/exists-file.svg?style=flat-square)](https://coveralls.io/github/Kikobeats/exists-file)
[![Dependency status](http://img.shields.io/david/Kikobeats/exists-file.svg?style=flat-square)](https://david-dm.org/Kikobeats/exists-file)
[![Dev Dependencies Status](http://img.shields.io/david/dev/Kikobeats/exists-file.svg?style=flat-square)](https://david-dm.org/Kikobeats/exists-file#info=devDependencies)
[![NPM Status](http://img.shields.io/npm/dm/exists-file.svg?style=flat-square)](https://www.npmjs.org/package/exists-file)
[![Donate](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square)](https://paypal.me/kikobeats)

> Check if a file exists. A fs.exists implementation that is not deprecated.

Because [fs.exist](https://nodejs.org/api/fs.html#fs_fs_exists_path_callback) and [fs.existsSync](https://nodejs.org/api/fs.html#fs_fs_existssync_path) are deprecated this an implementation using [fs.stats](https://nodejs.org/api/fs.html#fs_fs_stat_path_callback) and [fs.statsSync](https://nodejs.org/api/fs.html#fs_fs_statsync_path) for get the same result.

Also **always** keep in mind:

> fs.exists() should not be used to check if a file exists before calling fs.open(). Doing so introduces a race condition since other processes may change the file's state between the two calls. Instead, user code should call fs.open() directly and handle the error raised if the file is non-existent.

## Install

```bash
npm install exists-file --save
```

## Usage

```js
var existsFile = require('exists-file')

// async with a callback
existsFile('./README.md', console.log) // => null, true

// async with a promise
existsFile('./README.md').then(console.log).catch(console.error) // => true

// sync
var exists = existsFile.sync('./README.md')
console.log(exists) // => true
```

## API

### existsFile(filepath, [cb])

#### filepath

*Required* <br>
Type: `string`

The relative or absolute file path.

#### cb

Type: `function`

If `cb` is not provided then it returns a `promise`.

### existsFile.sync(filepath)

#### filepath

*Required* <br>
Type: `string`

The relative or absolute file path.

## License

MIT © [Kiko Beats](https://www.kikobeats.com)

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