Installation
Install @deessejs/errors in your TypeScript or JavaScript project.
Adding @deessejs/errors to your project is straightforward. The library is available on npm and supports all major package managers.
Install the Package
Choose your preferred package manager and run the installation command:
npm install @deessejs/errorspnpm add @deessejs/errorsyarn add @deessejs/errorsbun add @deessejs/errorsRequirements
@deessejs/errors requires Node.js 18 or later. The library is written in TypeScript and ships with full type definitions, so no additional @types packages are needed.
Import the Library
Once installed, you can import the core functions from the package:
import { error, raise, is, causes } from '@deessejs/errors';You can also import specific functions if you prefer tree-shaking:
import { error } from '@deessejs/errors';
import { is } from '@deessejs/errors';TypeScript Configuration
The library works out of the box with TypeScript. No special compiler options are required, but the following settings in your tsconfig.json will ensure the best experience:
{
"compilerOptions": {
"strict": true,
"moduleResolution": "bundler"
}
}The moduleResolution: "bundler" option is recommended if you're using a modern bundler like Vite, webpack 5, or Turbopack.
Verify Installation
To verify that the library is installed correctly, create a simple test file:
import { error } from '@deessejs/errors';
const TestError = error({ name: 'TestError' });
const err = TestError({});
console.log(err.name); // "TestError"
console.log(err instanceof Error); // trueRun this file with Node.js or your bundler to confirm everything works.