node-http-error provides a simple mechanism for creating and throwing HTTP-specific errors within Node.js applications, particularly useful for API development with frameworks like Express. This package allows developers to instantiate errors with a given HTTP status code, an optional custom message, and additional properties, while also automatically generating default messages for standard status codes. Key features of version 2.0.0, released in 2014, include full stack traces, the ability to omit the `new` operator when creating instances, and direct access to `status` and `statusCode` properties for integration with error handling middleware. However, this specific package by carsondarling is considered abandoned, with its last update occurring nine years ago. Developers are strongly encouraged to use more actively maintained alternatives like `http-errors` (from `jshttp`) for modern Node.js projects.
npm install node-http-errorVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create and throw `HTTPError` instances within an Express.js application, and how to set up a basic error handling middleware to catch and respond to these errors using their status code and message.
Migrate to a currently maintained alternative like `http-errors` (from `jshttp`) or `@curveball/http-errors`, which offer similar functionality with active development and modern JavaScript support.
For ESM projects, use an actively maintained package that provides ESM compatibility. If you must use this package in an ESM context, consider dynamic `import()` or transpilation, but migration is strongly recommended.
Upgrade to a modern HTTP error utility that is actively tested and maintained with current Node.js versions.
This package is CommonJS-only. Either refactor your project to use CommonJS, use dynamic `import()` (if compatible with your setup), or, preferably, migrate to a modern, actively maintained HTTP error library that supports ESM.
Ensure `require('node-http-error')` correctly resolves and that `HTTPError` is accessible in your scope. Verify file paths and npm installation. Given the package's age, ensure your Node.js environment is not causing compatibility issues during module loading.No dependency data recorded yet.