{"id":18430,"library":"http-error","title":"http-error","description":"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.","status":"maintenance","version":"0.0.6","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/c9/node-http-error","tags":["javascript"],"install":[{"cmd":"npm install http-error","lang":"bash","label":"npm"},{"cmd":"yarn add http-error","lang":"bash","label":"yarn"},{"cmd":"pnpm add http-error","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only and does not provide an ESM default export. Use require().","wrong":"import HttpError from 'http-error';","symbol":"HttpError (namespace)","correct":"const HttpError = require('http-error'); const err = new HttpError.NotFound('message');"},{"note":"Destructuring require works, but ESM import will fail. Only use CommonJS.","wrong":"import { NotFound } from 'http-error';","symbol":"NotFound","correct":"const { NotFound } = require('http-error'); const err = new NotFound('message');"},{"note":"Alternatively, destructure from require. All constructors are attached to the exported object.","wrong":null,"symbol":"InternalServerError","correct":"const InternalServerError = require('http-error').InternalServerError; const err = new InternalServerError('message');"}],"quickstart":{"code":"const HttpError = require('http-error');\nconst err = new HttpError.NotFound('Resource not found');\nconsole.log(err.status); // 404\nconsole.log(err.message); // Resource not found\nconsole.log(err instanceof Error); // true","lang":"javascript","description":"Creates an HTTP error object with a status code and message. Demonstrates basic usage of the NotFound constructor."},"warnings":[{"fix":"Use require() instead of import.","message":"The package is CommonJS-only. Using ES module import (import ... from) will fail with ERR_REQUIRE_ESM.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider migrating to actively maintained alternatives like http-errors or http-assert.","message":"Package has not been updated since 2014. It uses deprecated patterns like var and does not support TypeScript.","severity":"deprecated","affected_versions":"0.0.6"},{"fix":"Always use PascalCase constructors as defined in the README table (e.g., NotFound, InternalServerError).","message":"Constructor names are case-sensitive and some use non-standard casing (e.g., 'notFound' vs 'NotFound'). The README uses 'notFound' but actual names are PascalCase.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure you use PascalCase: new require('http-error').NotFound('msg')","cause":"Using wrong casing or importing incorrectly.","error":"TypeError: HttpError.NotFound is not a constructor"},{"fix":"Use dynamic import or convert your project to CommonJS. Alternatively, use a wrapper module with createRequire.","cause":"Package does not support ESM; using require() in an ESM environment.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module not supported"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}