# @rowanmanning/not-found

> Create Express middleware which results in an HTTP 404 Not Found error

Latest version **6.1.0** (published 2025-05-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @rowanmanning/not-found
pnpm add @rowanmanning/not-found
yarn add @rowanmanning/not-found
bun add @rowanmanning/not-found
```

## Health

**Score 45/100 (D)** — status: stable.

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

Warnings: low downloads; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 6.1.0 |
| Published | 2025-05-21 |
| First published | 2019-10-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | 20.x \|\| 22.x \|\| 24.x |
| Dependencies | 0 |
| Unpacked size | 4.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Rowan Manning |
| Maintainers | rowanmanning |
| Keywords | 404, express, middleware |

## Links

- npm: https://www.npmjs.com/package/@rowanmanning/not-found
- Repository: https://github.com/rowanmanning/not-found
- Issues: https://github.com/rowanmanning/not-found/issues
- npm.io page: https://npm.io/package/@rowanmanning/not-found

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 6.1.0 (latest) — 2025-05-21
- 6.0.0 — 2025-03-08
- 5.2.1 — 2024-07-27
- 5.2.0 — 2024-06-23
- 5.1.0 — 2024-01-30
- 5.0.0 — 2023-09-11
- 4.0.3 — 2023-07-25
- 4.0.2 — 2023-07-21
- 4.0.1 — 2023-04-18
- 4.0.0 — 2023-03-25
- 3.1.4 — 2023-02-14
- 3.1.3 — 2023-01-08
- 3.1.2 — 2022-11-14
- 3.1.1 — 2022-07-09
- 3.1.0 — 2022-06-10
- … 14 more at https://npm.io/package/@rowanmanning/not-found/versions

## README

# @rowanmanning/not-found

Create Express middleware which results in an HTTP 404 Not Found error.

* [Requirements](#requirements)
* [Usage](#usage)
* [Migration](#migration)
* [Contributing](#contributing)
* [License](#license)


## Requirements

This library requires the following to run:

  * [Node.js](https://nodejs.org/) 20+


## Usage

Install with [npm](https://www.npmjs.com/):

```sh
npm install @rowanmanning/not-found
```

Load the library into your code with a `require` call:

```js
const { notFound } = require('@rowanmanning/not-found');
```

Create middleware which results in an HTTP 404 error in [Express](https://expressjs.com):

```js
const express = require('express');
const { notFound } = require('@rowanmanning/not-found');

const app = express();

app.use(notFound());
```

Handle the 404 error like you would any other error in Express:

```js
app.use((error, request, response, next) => {
    response.status(error.status); // 404
    response.send(error.message); // Not Found
});
```

Customise the error message with an option:

```js
app.use(notFound({
    message: 'This page does not exist'
}));

app.use((error, request, response, next) => {
    response.status(error.status); // 404
    response.send(error.message); // This page does not exist
});
```


## Migration

A new major version of this project is released if breaking changes are introduced. We maintain a [migration guide](docs/migration.md) to help users migrate between these versions.


## Contributing

[The contributing guide is available here](docs/contributing.md). All contributors must follow [this library's code of conduct](docs/code_of_conduct.md).


## License

Licensed under the [MIT](LICENSE) license.<br/>
Copyright &copy; 2019, Rowan Manning

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