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

error-explainer

v1.0.0

Published

Transforms cryptic JavaScript/TypeScript error messages into human-readable explanations with actionable fix suggestions.

Readme

error-explainer

Transform cryptic JavaScript & TypeScript error messages into human-readable explanations with actionable fix suggestions.

npm version zero dependencies TypeScript license: MIT


Why?

Error messages like Cannot read properties of undefined (reading 'name') are confusing — especially for beginners and junior developers. error-explainer translates them into plain English with a clear reason and a concrete fix suggestion.

Perfect for:

  • 🧑‍💻 Beginner-friendly developer tools
  • 🤖 AI-powered IDEs and coding assistants
  • 🛠️ Custom error dashboards and loggers
  • 📚 Learning platforms and code editors

Install

npm install error-explainer

Quick Start

import { explain } from 'error-explainer';

const result = explain("Cannot read properties of undefined (reading 'name')");

console.log(result);
// {
//   original:   "Cannot read properties of undefined (reading 'name')",
//   reason:     "You are trying to access the property `name` on a value that is `undefined`.",
//   suggestion: "Add a null-check before accessing the property: `if (value) { value.name }` or use optional chaining: `value?.name`.",
//   category:   "TypeError",
//   severity:   "high"
// }

API

explain(error, options?)

Explains a single error. Accepts a string, an Error object, or any unknown thrown value.

import { explain } from 'error-explainer';

// From a string
explain("user is not defined");

// From a caught Error object
try {
  doSomething();
} catch (err) {
  const info = explain(err);
  console.log(info.reason);
  console.log(info.suggestion);
}

Options

| Option | Type | Default | Description | |------------------|---------|---------|------------------------------------------| | includeCauses | boolean | false | Include a commonCauses string array | | includeDocs | boolean | false | Include an MDN/docs URL when available |

explain("Cannot find module 'react'", {
  includeCauses: true,
  includeDocs: true,
});
// {
//   ...
//   commonCauses: ["Package not installed (`npm install` not run)", ...],
//   docs: "https://nodejs.org/api/modules.html"
// }

quickExplain(error)

Returns only reason and suggestion — ideal for tooltips and compact logging.

import { quickExplain } from 'error-explainer';

quickExplain("Maximum call stack size exceeded");
// {
//   reason:     "A function is calling itself without a proper base case ...",
//   suggestion: "Add a base/termination condition to your recursive function ..."
// }

explainAll(errors, options?)

Explain multiple errors at once.

import { explainAll } from 'error-explainer';

const results = explainAll([
  "Failed to fetch",
  "Assignment to constant variable",
  new TypeError("foo is not a function"),
]);

Return Type: ExplainedError

interface ExplainedError {
  original:      string;          // The raw input error message
  reason:        string;          // Human-readable explanation
  suggestion:    string;          // Actionable fix
  category:      ErrorCategory;  // "TypeError" | "ReferenceError" | ...
  severity:      "low" | "medium" | "high";
  commonCauses?: string[];        // With includeCauses: true
  docs?:         string;          // With includeDocs: true
}

Supported Error Types

| Category | Example Message | |------------------|--------------------------------------------------------------| | TypeError | Cannot read properties of undefined (reading 'x') | | TypeError | Cannot read properties of null | | TypeError | foo is not a function | | TypeError | Assignment to constant variable | | TypeError | undefined is not iterable | | ReferenceError | user is not defined | | SyntaxError | Unexpected token '}' | | SyntaxError | Unexpected end of input | | RangeError | Maximum call stack size exceeded | | PromiseError | Unhandled promise rejection | | NetworkError | Failed to fetch / net::ERR_* | | ModuleError | Cannot find module 'react' |


Integration Example — Express Error Handler

import { explain } from 'error-explainer';

app.use((err, req, res, next) => {
  const info = explain(err, { includeCauses: true });
  res.status(500).json({
    error:      info.original,
    reason:     info.reason,
    suggestion: info.suggestion,
    severity:   info.severity,
  });
});

Integration Example — React Error Boundary

import { explain } from 'error-explainer';

class ErrorBoundary extends React.Component {
  componentDidCatch(error: Error) {
    const info = explain(error);
    console.warn(`[${info.severity.toUpperCase()}] ${info.reason}`);
    console.info(`Fix: ${info.suggestion}`);
  }
}

License

MIT © error-explainer contributors