Registry / http-networking / http-error

http-error

JSON →
library0.0.6jsnpmunverified

Exposes HTTP error codes as Error constructors for Node.js. This package (v0.0.6, last updated in 2014) provides a simple way to create HTTP error objects with status codes (e.g., NotFound, InternalServerError). It is a lightweight alternative to packages like http-errors or boom, but with a smaller API surface and no dependency on Express. Currently in maintenance mode; no releases since 2014.

npm install http-error
INSTALL
IMPORT
SIG · HTTP-ERROR
H
http-error
http-networkingjavascriptv0.0.6
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

HttpError (namespace)
const HttpError = require('http-error'); const err = new HttpError.NotFound('message');
import HttpError from 'http-error';
This package is CommonJS-only and does not provide an ESM default export. Use require().
NotFound
const { NotFound } = require('http-error'); const err = new NotFound('message');
import { NotFound } from 'http-error';
Destructuring require works, but ESM import will fail. Only use CommonJS.
InternalServerError
const InternalServerError = require('http-error').InternalServerError; const err = new InternalServerError('message');
Alternatively, destructure from require. All constructors are attached to the exported object.

Creates an HTTP error object with a status code and message. Demonstrates basic usage of the NotFound constructor.

const HttpError = require('http-error'); const err = new HttpError.NotFound('Resource not found'); console.log(err.status); // 404 console.log(err.message); // Resource not found console.log(err instanceof Error); // true
Debug
Known issues
gotchaThe package is CommonJS-only. Using ES module import (import ... from) will fail with ERR_REQUIRE_ESM.
fix
Use require() instead of import.
affects: >=0.0.0
deprecatedPackage has not been updated since 2014. It uses deprecated patterns like var and does not support TypeScript.
fix
Consider migrating to actively maintained alternatives like http-errors or http-assert.
affects: 0.0.6
gotchaConstructor names are case-sensitive and some use non-standard casing (e.g., 'notFound' vs 'NotFound'). The README uses 'notFound' but actual names are PascalCase.
fix
Always use PascalCase constructors as defined in the README table (e.g., NotFound, InternalServerError).
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: HttpError.NotFound is not a constructor
Using wrong casing or importing incorrectly.
fix
Ensure you use PascalCase: new require('http-error').NotFound('msg')
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Package does not support ESM; using require() in an ESM environment.
fix
Use dynamic import or convert your project to CommonJS. Alternatively, use a wrapper module with createRequire.
Upgrade
Version history
0.0.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
http-error — npm install http-error · libregistry