{"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,"search_vec":"'2014':19,66 'altern':39 'api':52 'boom':47 'code':7,31 'constructor':10 'creat':25 'current':59 'depend':56 'e.g':32 'error':3,6,9,27,45 'expos':4 'express':58 'http':2,5,26,44 'http-error':1,43 'internalservererror':34 'javascript':67 'last':16 'lightweight':38 'like':42 'mainten':61 'mode':62 'node.js':12 'notfound':33 'object':28 'packag':14,41 'provid':20 'releas':64 'simpl':22 'sinc':65 'smaller':51 'status':30 'surfac':53 'updat':17 'v0.0.6':15 'way':23","created_at":"2026-04-25T07:38:12.047994+00:00","updated_at":"2026-04-25T07:38:12.047994+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/c9/node-http-error","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/http-error","openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}