# errx

> Zero dependency library to capture and parse stack traces in Node, Bun and Deno

Latest version **0.2.1** (published 2026-09-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install errx
pnpm add errx
yarn add errx
bun add errx
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2026-09-16 |
| First published | 2024-07-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 97 |
| Maintainers | danielroe |

## Links

- npm: https://www.npmjs.com/package/errx
- Repository: https://github.com/danielroe/errx
- Homepage: https://github.com/danielroe/errx#readme
- Issues: https://github.com/danielroe/errx/issues
- npm.io page: https://npm.io/package/errx

## Recent versions

- 0.2.1 (latest) — 2026-09-16
- 0.2.0 — 2026-09-03
- 0.1.2 — 2026-07-28
- 0.1.0 — 2024-07-04
- 0.0.1 — 2024-07-04
- 0.0.0 — 2024-07-04

## README

# errx

[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![Github Actions][github-actions-src]][github-actions-href]
[![Codecov][codecov-src]][codecov-href]

> Zero dependency library to capture and parse stack traces in Node, Bun, Deno and more.

## Usage

Install package:

```sh
# npm
npm install errx

# pnpm
pnpm install errx
```

```js
import { captureRawStackTrace, captureStackTrace, parseError, parseRawStackTrace } from 'errx'

// returns raw string stack trace
captureRawStackTrace()
// returns parsed stack trace
captureStackTrace()
// parses the stack of an existing error (empty array if it has none)
parseError(error)
// parses a stack trace string
parseRawStackTrace(error.stack)

console.log(captureStackTrace())
// [{
//   function: undefined,
//   source: 'file:///code/danielroe/errx/playground/index.js',
//   line: 5,
//   column: 13
// }]
```

### `ParsedTrace`

```ts
interface ParsedTrace {
  column?: number
  function?: string
  line?: number
  source: string
  isAsync?: boolean
  isConstructor?: boolean
  isEval?: boolean
  isNative?: boolean
  raw?: string
}
```

`function` holds the bare function name; V8's `async` and `new` prefixes are surfaced as `isAsync` and `isConstructor` instead. Frames with no resolvable location (`at Array.map (<anonymous>)`, `at moduleEvaluation (native)`) are kept, with `isNative` set and no `line`/`column`. For `eval` frames (`at eval (eval at fn (file.js:1:2), <anonymous>:3:4)`), `isEval` is set and `source`/`line`/`column` point at the innermost real file location rather than the position inside the evaluated code.

Absolute filesystem paths are normalised to `file://` URLs, including Windows drive paths (`C:\x\y.js` becomes `file:///C:/x/y.js`) and UNC paths (`\\server\share\x.js` becomes `file://server/share/x.js`). Sources that already have a scheme are left untouched.

The `is*` flags are only present when `true`. `raw` holds the original stack trace line. Lines that are recognisably frames but whose shape cannot be parsed are still returned, with an empty `source`, so they can be rendered from `raw`.

## 💻 Development

- Clone this repository
- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`
- Install dependencies using `pnpm install`
- Run interactive tests using `pnpm dev`

## License

Made with ❤️

Published under [MIT License](./LICENCE).

<!-- Badges -->

[npm-version-src]: https://npmx.dev/api/registry/badge/version/errx
[npm-version-href]: https://npmx.dev/package/errx
[npm-downloads-src]: https://npmx.dev/api/registry/badge/downloads/errx
[npm-downloads-href]: https://npm.chart.dev/errx
[github-actions-src]: https://img.shields.io/github/actions/workflow/status/danielroe/errx/ci.yml?branch=main&style=flat-square
[github-actions-href]: https://github.com/danielroe/errx/actions?query=workflow%3Aci
[codecov-src]: https://img.shields.io/codecov/c/gh/danielroe/errx/main?style=flat-square
[codecov-href]: https://codecov.io/gh/danielroe/errx

---
_Source: https://npm.io/package/errx · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
