{"id":40763,"library":"create-http-error","title":"create-http-error","description":"This package (version 1.0.3) provides a simple factory function to create HTTP error objects with a given numeric status code. It was last released in an earlier era and is not actively maintained. The error object includes the code, standard HTTP message, and optional custom message or properties. It exposes `.toString()`, `.toJSON()`, and a `.codes` property. It only supports CommonJS (require) and is intended for Node.js environments. No releases have been made in years, and the package may be considered stable but deprecated in favor of more modern alternatives like 'http-errors' or 'http-errors-promise'. Usage with ESM (import) may fail without a wrapper.","status":"deprecated","version":"1.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/intesso/create-http-error","tags":["javascript","http","error"],"install":[{"cmd":"npm install create-http-error","lang":"bash","label":"npm"},{"cmd":"yarn add create-http-error","lang":"bash","label":"yarn"},{"cmd":"pnpm add create-http-error","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package exposes module.exports, not a default ESM export. Use CommonJS require() in Node.","wrong":"import HttpError from 'create-http-error'","symbol":"HttpError","correct":"const HttpError = require('create-http-error')"},{"note":"If using ESM, the entire module is exported as a function. A named destructure is incorrect.","wrong":"const { HttpError } = require('create-http-error')","symbol":"HttpError (ESM)","correct":"import HttpError from 'create-http-error'"},{"note":"Accessing .codes via require or default import; named ESM import is not supported.","wrong":"import { codes } from 'create-http-error'","symbol":"HttpError.codes","correct":"const codes = require('create-http-error').codes"}],"quickstart":{"code":"const HttpError = require('create-http-error');\n\n// Create an error with status 400\nconst err400 = HttpError(400);\nconsole.log(err400.status); // 400\nconsole.log(err400.message); // 'Bad Request'\nconsole.log(err400.toString()); // 'HttpError 400: Bad Request'\n\n// With custom message\nconst err404 = HttpError(404, 'Not found');\nconsole.log(err404.message); // 'Not found'\n\n// With properties\nconst err500 = HttpError(500, 'Server error', { custom: true });\nconsole.log(err500.custom); // true\n\n// Using .codes\nconsole.log(HttpError.codes[200]); // 'OK'","lang":"javascript","description":"Shows creating HTTP errors with code, message, properties, and accessing status codes."},"warnings":[{"fix":"Switch to http-errors: const createError = require('http-errors'); createError(400);","message":"Package is unmaintained since 2015. Use 'http-errors' or 'http-errors-promise' instead.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Always pass a number: HttpError(400).","message":"Passing a string to HttpError works (e.g., '400') but is not documented as intended; it coerces to number.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use CommonJS require() or wrap with createRequire.","message":"The package does not support ESM import natively. Attempting import will fail or require .mjs config.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'1.0.3':8 'activ':36 'altern':93 'code':24,43,59 'commonj':64 'consid':84 'creat':2,15 'create-http-error':1 'custom':49 'deprec':87 'earlier':31 'environ':71 'era':32 'error':4,17,39,97,101,114 'esm':105 'expos':54 'factori':12 'fail':108 'favor':89 'function':13 'given':21 'http':3,16,45,96,100,113 'http-error':95 'http-errors-promis':99 'import':106 'includ':41 'intend':68 'javascript':112 'last':27 'like':94 'made':76 'maintain':37 'may':82,107 'messag':46,50 'modern':92 'node.js':70 'numer':22 'object':18,40 'option':48 'packag':6,81 'promis':102 'properti':52,60 'provid':9 'releas':28,73 'requir':65 'simpl':11 'stabl':85 'standard':44 'status':23 'support':63 'tojson':56 'tostr':55 'usag':103 'version':7 'without':109 'wrapper':111 'year':78","created_at":"2026-06-04T18:49:07.863438+00:00","updated_at":"2026-06-04T18:49:07.863438+00:00","problems":[{"fix":"Use const HttpError = require('create-http-error');","cause":"Using named import instead of default import with require.","error":"TypeError: HttpError is not a function"},{"fix":"Run npm install create-http-error --save","cause":"Package not installed or not found in node_modules.","error":"Cannot find module 'create-http-error'"},{"fix":"If using ES modules, use import HttpError from 'create-http-error' or switch to CommonJS.","cause":"Using ES modules without proper import or require.","error":"HttpError is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/intesso/create-http-error","github":"https://github.com/intesso/create-http-error","docs":null,"changelog":null,"pypi":null,"npm":"create-http-error","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}