Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A lightweight CLI that explains JavaScript/Node.js errors in plain English and suggests fixes.

License

Notifications You must be signed in to change notification settings

BeyteFlow/errlens

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

90 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

ErrLens πŸ”

Translate cryptic JavaScript errors into human-readable solutions instantly.



GitHub stars GitHub forks GitHub issues GitHub license Open PRs
npm version npm downloads Git tag version Node.js version

**ErrLens** is a professional-grade CLI utility designed to eliminate developer frustration. It intercepts Node.js crashes, analyzes stack traces, and delivers plain-English explanations with actionable fixesβ€”directly in your terminal.





🌟 Key Features

  • πŸš€ Instant Diagnostics – No more context-switching to Google or StackOverflow.
  • πŸ”„ Live Monitoring – Catch errors in real-time using the errlens run command.
  • 🧠 Fuzzy Logic Engine – Matches messy stack traces and typos using Fuse.js.
  • 🎨 Beautiful UI – High-visibility terminal output powered by boxen and chalk.
  • πŸ€– CI/CD Ready – Export raw data via --json for automated error reporting.

πŸ“¦ Installation

Install globally via npm to use the errlens command anywhere in your terminal:

npm install -g errlens

πŸ›  Usage

1️⃣ Automatic Monitoring (The "Pro" Way)

Run your script through ErrLens. If it crashes, ErrLens intercepts the error and explains the fix before the process exits.

errlens run your-app.js

2️⃣ Manual Analysis

Found a weird error in your logs? Just paste the message:

errlens "TypeError: Cannot read properties of undefined"

3️⃣ Pipeline Integration

Get machine-readable results for your own tooling or automated reports:

errlens "is not a function" --json

Run a script and write the JSON report directly to a file in CI:

errlens run test.js --json > ci-report.json

In --json mode, ErrLens prints only JSON (no spinner, colors, or terminal boxes).

Example response from run:

{
  "code": 0,
  "count": 0,
  "matches": []
}

Example response from analyze <errorString> (match found):

{
  "code": 1,
  "count": 1,
  "matches": [
    {
      "name": "TypeError: Cannot read properties of undefined",
      "match": "Cannot read properties of undefined",
      "explanation": "You are trying to access a property on a variable that is currently empty.",
      "why": "The variable wasn't initialized, or an API call hasn't finished yet.",
      "fixes": [
        "Use optional chaining: user?.name",
        "Set a default value: data || []"
      ],
      "example": "const name = user?.name || 'Guest';"
    }
  ]
}

Exit codes (useful for CI):

  • run <file> exits with the child process exit code.
  • analyze <errorString> exits with 1 when matches are found (intentional, so CI can fail when known errors are detected), otherwise 0.

This follows Unix conventions where 0 means success and non-zero means failure. If you prefer success-on-detection in CI, invert the check in your pipeline logic (for example, treat exit code 1 from analyze <errorString> as a pass condition).


🧠 System Architecture

ErrLens operates on a three-stage intelligent pipeline to turn confusion into clarity:

Phase Component Description
Interception auto.js Hooks into the uncaughtException event via a preload script.
Matching matcher.js Uses fuzzy search against database.json to find the root cause.
Formatting formatter.js Wraps the diagnosis in a clean, color-coded terminal interface.

πŸ“ Project Structure

errlens/
β”œβ”€β”€ bin/index.js       # CLI Entry point & Command routing
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ matcher.js     # Fuzzy search & Logic engine
β”‚   β”œβ”€β”€ formatter.js   # UI & Terminal styling
β”‚   β”œβ”€β”€ auto.js        # Automation & Error interception
β”‚   └── database.json  # The "Knowledge Base" (Dictionary)
β”œβ”€β”€ package.json       # Dependencies & Metadata
└── README.md          # Documentation

🀝 Contributing

We are building the world's most comprehensive dictionary of JavaScript errors, and we need your help!

  1. Fork the repository.
  2. Add a new error entry to lib/database.json.
  3. Submit a Pull Request.

πŸ’‘ Tip: Every error you add helps another developer save valuable time. Join the mission!


πŸ“ License

Distributed under the MIT License. See LICENSE for more information.


Built with ❀️ by BeyteFlow
Making the terminal a friendlier place, one error at a time.

About

A lightweight CLI that explains JavaScript/Node.js errors in plain English and suggests fixes.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors