# file-exists

> Check if filepath exists and is a file

Latest version **5.0.1** (published 2018-01-02) · MIT license · 0 weekly downloads

## Install

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

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.1 |
| Published | 2018-01-02 |
| First published | 2014-07-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/file-exists) |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 33 |
| Author | Scott Corgan |
| Maintainers | scottcorgan |
| Keywords | file, exists, fs, isfile, is-file |

## Links

- npm: https://www.npmjs.com/package/file-exists
- Repository: https://github.com/scottcorgan/file-exists
- Issues: https://github.com/scottcorgan/file-exists/issues
- npm.io page: https://npm.io/package/file-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.1 (latest) — 2018-01-02
- 5.0.0 — 2017-09-27
- 4.0.0 — 2017-06-01
- 3.0.2 — 2017-03-08
- 3.0.1 — 2017-02-07
- 3.0.0 — 2017-02-07
- 2.0.0 — 2016-08-02
- 1.0.0 — 2015-11-20
- 0.1.1 — 2014-07-18
- 0.1.0 — 2014-07-17

## README

# file-exists

Check if filepath exists and is a file. Returns false for directories.

_(Requires node >=6.0.0)_

## Install

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

## Usage

```js
const fileExists = require('file-exists');

fileExists('/index.html', (err, exists) => console.log(exists)) // OUTPUTS: true or false

fileExists('/index.html').then(exists => {
  console.log(exists) // OUTPUTS: true or false
})

console.log(fileExists.sync('/index.html')) // OUTPUTS: true or false
```

### Options

#### fileExists(filepath[, options, callback])

* `filepath` - the path to the file to check if it exists
* `options` - an object of options
  * `root` - the root directory to look in (or cwd)
* `callback(err, exists)` - gets called when checking is done

#### fileExists.sync(filepath[, options])
* `filepath` - the path to the file to check if it exists
* `options` - an object of options
  * `root` - the root directory to look in (or cwd)

## Run Tests

```
npm install
npm test
```

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