The `common-errors` package provides a comprehensive suite of custom error classes for Node.js, designed to offer more specific error types than native JavaScript `Error` objects. Originally intended to mirror error types found in other modern languages, it includes classes like `AlreadyInUseError`, `ArgumentError`, `NotFoundError`, and `AuthenticationRequiredError`. Key features highlighted in its documentation include the ability to append stack traces from asynchronously generated errors, dynamically generate custom error classes, and map HTTP status codes to errors for web service integration. The current stable version is 1.2.0. However, the package has not seen active development or updates in many years, with its last release dating back to 2017. Consequently, it is no longer actively maintained.
npm install common-errorsVerified import paths — ran on the pinned version, not inferred.
Demonstrates the creation and catching of various common error types, custom error generation, and the utility for prepending stack traces from inner errors.
Consider migrating to a more actively maintained error utility library or implementing custom error classes yourself. Evaluate security implications carefully.
Use `const errors = require('common-errors');` for CommonJS environments. For ESM projects, you might need Node.js's interoperability features or a bundler to consume this CJS package, or use dynamic `import()` if applicable.Thoroughly test compatibility with your target Node.js version. If issues arise, consider alternative, more modern error handling libraries.
Perform a security audit of your dependencies. If security is critical, replacing this library with a maintained alternative is strongly recommended.
If `common-errors` is the CJS module: use `const errors = require('common-errors');`. If your project is ESM and you need to consume this CJS module, ensure Node.js interoperability is configured, or use a dynamic `import()` if suitable.Add `const errors = require('common-errors');` at the top of your file to make the error classes available.Verify that `common-errors` is correctly `require()`d and that `generateClass` is used with valid arguments. Ensure the base class (second argument) if provided, is a valid constructor function.
Run `npm install common-errors` to install the package. Double-check the module name in your `require()` statement.
No dependency data recorded yet.