Beautiful stack trace formatter with source code context for JavaScript.
- 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
Choose your preferred package manager:
# npm package
npm install @neabyte/stackz
# Deno module
deno add jsr:@neabyte/stackzimport Stackz from '@neabyte/stackz'
try {
// Your code that might throw
throw new Error('Something went wrong')
} catch (error) {
// Compact format without source context
console.log(Stackz.format(error, 'compact'))
// Detailed format with source context
console.log(await Stackz.format(error, 'detailed'))
}TypeError Cannot read properties of undefined (reading 'property')
→ createTypeError @ index.ts:5:14
→ index.ts:15:3
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
This project is licensed under the MIT license. See the LICENSE file for more info.
