Skip to content

Repository files navigation

Stackz Module type: CJS+ESMnpm versionJSRNode.js CI

Beautiful stack trace formatter with source code context for JavaScript.

Demo

Features

  • Cross-runtime support - Works in Deno, Node.js, Bun, and browsers
  • Source code context - Shows actual code around error locations (detailed mode)
  • Two formatting styles - Compact and detailed stack traces
  • ANSI colors - Beautiful terminal output with syntax highlighting

Installation

Choose your preferred package manager:

# npm package
npm install @neabyte/stackz
# Deno module
deno add jsr:@neabyte/stackz

Usage

importStackzfrom'@neabyte/stackz'try{// Your code that might throwthrownewError('Something went wrong')}catch(error){// Compact format without source contextconsole.log(Stackz.format(error,'compact'))// Detailed format with source contextconsole.log(awaitStackz.format(error,'detailed'))}

Formats

Compact

TypeError Cannot read properties of undefined (reading 'property')
→ createTypeError @ index.ts:5:14
→ index.ts:15:3

Detailed

TypeError Cannot read properties of undefined (reading 'property')
Path: /path/to/project/index.ts:5:14
2 |
3 | function createTypeError() {
4 | const obj = undefined as any
5 return obj.property // This will create TypeError with real stack
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6 | }
Call Stack:
• createTypeError → index.ts:5:14
• anonymous → index.ts:15:3

License

This project is licensed under the MIT license. See the LICENSE file for more info.

Releases

Packages

Contributors

Languages