npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cleaner-errors

v0.1.2

Published

Human-readable error messages for Zod, Prisma, tRPC and more — drop-in CLI wrapper for Node.js and TypeScript projects

Downloads

45

Readme

cleaner-errors

Your Node.js errors are lying to you.

Not intentionally. But when Zod throws a wall of JSON, when Prisma says P2002 like you're supposed to know what that means, when TypeScript runtime explodes with Cannot read properties of undefined (reading 'map') — you're not getting an error. You're getting a puzzle.

cleaner-errors wraps your run command and translates that noise into plain English. No config. No code changes. One prefix.

npm install -g cleaner-errors

Before / After

Before — what you're dealing with today:

ZodError: [
  {
    "code": "invalid_type",
    "expected": "string",
    "received": "undefined",
    "path": ["user", "email"],
    "message": "Required"
  },
  {
    "code": "too_small",
    "minimum": 8,
    "type": "string",
    "path": ["user", "password"],
    "message": "String must contain at least 8 character(s)"
  }
]

After — what you actually need:

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 Zod  ZodError
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

What went wrong
  2 fields failed validation:
  • user.email: Expected string, got undefined
  • user.password: Must be at least 8 character(s)

Affected field(s)
  ◆ user.email
  ◆ user.password

Suggested fix
  Make sure your input includes all required fields:
  user.email: <valid value>

docs → zod.dev/ERROR_HANDLING

Same error. Ten seconds instead of ten minutes.


Usage

Just prefix your existing run command. That's it.

# node
cleaner-errors node server.js

# tsx / ts-node
cleaner-errors npx tsx src/index.ts
cleaner-errors ts-node src/index.ts

# bun
cleaner-errors bun run src/index.ts

# anything, really
cleaner-errors npx whatever src/index.ts

No wrapping your code. No try/catch boilerplate. No setup. It intercepts stderr, recognises the error, and tells you what went wrong.


What it catches

| Library | Errors | |---|---| | Zod | Every issue code — invalid_type, too_small, too_big, invalid_enum_value, and more. Shows every failing field at once. | | Prisma | P2002 unique constraint, P2003 foreign key, P2025 record not found, P2016 query error, P1001 can't reach database | | Node.js | Cannot read properties of undefined, is not a function, fetch failures, Maximum call stack size exceeded, MODULE_NOT_FOUND |

tRPC parser shipping in v0.2.


Programmatic API

Prefer dropping it into your own code? That works too.

import { enhance, parse, withEnhance } from 'cleaner-errors';

enhance(err) — print + re-throw. Drop it in any catch block:

try {
  await createUser(input);
} catch (err) {
  throw enhance(err); // prints the good stuff, re-throws the original
}

withEnhance(fn) — wrap a whole function:

const start = withEnhance(async () => {
  await server.listen(3000);
});

await start();

parse(err) — just give me the data, I'll handle the output:

try {
  await createUser(input);
} catch (err) {
  const info = parse(err);

  logger.error({
    source: info.source,   // "Zod"
    what:   info.what,     // plain-English explanation
    fields: info.fields,   // ["user.email", "user.password"]
    fix:    info.fix,      // suggested fix
    docs:   info.docs,     // link to docs
  });
}

Options

cleaner-errors --help      # usage
cleaner-errors --version   # version

Set NO_COLOR=1 to strip ANSI — useful for log files, CI, or piping output somewhere.


Why not just read the error?

You can. But you shouldn't have to spend 5 minutes cross-referencing Prisma's error reference docs to find out that P2002 means "that email already exists." Or parsing a Zod issue array by hand to figure out which of your 12 fields failed validation. Or googling Cannot read properties of undefined for the fourth time this week.

These are solved problems. The libraries know exactly what went wrong. They just don't tell you clearly. cleaner-errors is the translation layer.


Contributing

Parsers are small, self-contained, and easy to add. If your favourite library throws cryptic errors, open a PR.

Each parser is two functions:

// src/parsers/mylibrary.ts

export function isMyLibraryError(err: unknown): boolean {
  return (err as any)?.name === 'MyLibraryError';
}

export function parseMyLibraryError(err: unknown): EnhancedError {
  return {
    source: 'MyLibrary',
    type:   'MyLibraryError',
    what:   'Plain-English explanation.',
    fields: ['the.affected.field'],
    fix:    'What to do about it, with a code snippet.',
    docs:   'https://mylibrary.dev/errors',
  };
}

Register it in src/index.ts and you're done.

git clone https://github.com/YOUR_USERNAME/cleaner-errors
cd cleaner-errors
npm install
npm run dev

License

MIT