Youch is an error-parsing library designed to transform raw JavaScript error stack traces into highly readable and visually appealing output. It can render these errors into self-contained HTML pages for web contexts or formatted ANSI output for terminal environments. The current stable version is 4.1.1, with frequent updates, including beta releases for new features and bug fixes. A key differentiator is its ability to provide detailed error information, including code snippets, request/response metadata, and configurable links to code editors, significantly enhancing the developer experience compared to standard unformatted stack traces. It is widely adopted by frameworks like Hono, Nuxt, and AdonisJS, emphasizing its utility in modern web development workflows.
npm install youchVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to integrate Youch into a Node.js HTTP server to catch errors and render them as a rich, self-contained HTML error page.
Migrate your project to use ES Modules (`import`/`export`) or use dynamic `import()` for Youch if you must remain in a CommonJS environment.
Update your import statements to use named import syntax: `import { Youch } from 'youch'`.Instantiate `Youch` without arguments: `const youch = new Youch()`. Then, pass the `error` and `request` context when calling a rendering method, e.g., `await youch.toHTML(error, request)`.
Upgrade to Youch v4.1.0 or later to ensure proper HTML escaping. If using an older version, manually sanitize any potentially untrusted input before it is incorporated into error messages.
If encountering issues related to missing modules, ensure these dependencies are properly installed and linked, potentially by adding them explicitly to your `package.json`.
Change the import statement to `import { Youch } from 'youch'` to use the named export.Refactor your module to use ES Modules, or if absolutely necessary, use a dynamic import: `const { Youch } = await import('youch')` in an `async` context. Otherwise, downgrade Youch to a version prior to 4.1.0.Ensure `error` and `request` (or `null` for `request` if not applicable) are passed as arguments to the rendering methods: `await youch.toHTML(error, request)`.