Registry / observability / error-stack-parser-es

error-stack-parser-es

JSON →
library1.0.5jsnpmunverified

error-stack-parser-es is a modern, TypeScript-rewritten port of the original `stacktracejs/error-stack-parser` library, specifically designed for ES Modules environments. It provides robust functionality for parsing JavaScript `Error` objects and extracting detailed stack frame information, making it suitable for error reporting and debugging tools. The current stable version is 1.0.5, which recently adopted an 'Epoch SemVer' strategy, indicating a potential shift in versioning philosophy without a breaking change in behavior from the previous major release. It offers both a standard API and a 'lite' version with simplified stack frame representations (e.g., `line` and `col` instead of `lineNumber` and `columnNumber`) and the ability to parse raw stacktrace strings, providing flexibility for different use cases. Its key differentiators include native TypeScript support, ES Modules first design, and a streamlined 'lite' API.

npm install error-stack-parser-es
INSTALL
IMPORT
SIG · ERROR-STACK-PARSER
E
error-stack-parser-es
observabilityjavascriptv1.0.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse
import { parse } from 'error-stack-parser-es'
const { parse } = require('error-stack-parser-es')
This package is ESM-first and ships TypeScript types. Use named imports.
parse
import { parse } from 'error-stack-parser-es/lite'
import parseLite from 'error-stack-parser-es/lite'
The 'lite' version offers a simplified stack frame structure (e.g., `line`, `col`) and can be imported from a subpath.
parseStack
import { parseStack } from 'error-stack-parser-es/lite'
Available only in the 'lite' version, this function allows parsing raw stacktrace strings directly. It does not support Opera's stacktrace format.

Demonstrates parsing an `Error` object using both the standard and 'lite' APIs, and parsing a raw stack string with the 'lite' API.

import { parse } from 'error-stack-parser-es'; import { parse as parseLite, parseStack } from 'error-stack-parser-es/lite'; function simulateError() { try { throw new Error('This is a test error to demonstrate stack parsing!'); } catch (err) { return err; } } const errorInstance = simulateError(); // Using the standard API const standardStackFrames = parse(errorInstance); console.log('Standard Stack Frames:', standardStackFrames[0].fileName, standardStackFrames[0].lineNumber); // Using the Lite API for simplified frames const liteStackFrames = parseLite(errorInstance); console.log('Lite Stack Frames:', liteStackFrames[0].file, liteStackFrames[0].line); // Parsing a raw stack string with the Lite API const rawStackString = 'Error\n at myFunction (bundle.js:10:5)\n at anotherFunc (main.js:20:10)'; const parsedFromString = parseStack(rawStackString); console.log('Parsed from string:', parsedFromString[0].name, parsedFromString[0].col);
Debug
Known issues
breakingThe package moved from `v0.x.x` directly to `v1.0.x` and adopted 'Epoch SemVer'. While v1.0.5 had no behavioral changes from the previous version, be aware that future `v1.x.x` releases might introduce breaking changes without a major version increment in the traditional SemVer sense. Always review release notes.
fix
Thoroughly review release notes for versions `1.x.x` and above before upgrading, as 'Epoch SemVer' implies breaking changes might occur within the '1' epoch.
affects: >=1.0.5
gotchaThe `error-stack-parser-es/lite` version's `parseStack` function, which parses raw stacktrace strings, does not support the Opera browser's unique stacktrace format. If you need to parse Opera stack traces, you must use the standard `parse` function with an actual `Error` object.
fix
For Opera stack traces, ensure you capture and pass an `Error` object to `import { parse } from 'error-stack-parser-es'` instead of a raw string to `parseStack`.
affects: >=0.1.3
gotchaThis library is primarily designed for ES Modules (ESM). While bundlers can often handle CommonJS compatibility, direct `require()` calls in Node.js environments might lead to issues or require specific configuration for interoperability.
fix
Always use `import` statements for `error-stack-parser-es`. If working in a CommonJS-only Node.js environment, consider using dynamic `import()` or transpiling your code.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'split')
Attempting to parse an invalid or `null`/`undefined` Error object or stack string.
fix
Ensure the input to `parse` or `parseStack` is a valid `Error` instance or a non-empty string representing a stack trace.
SyntaxError: Named export 'parse' not found. The requested module 'error-stack-parser-es' does not provide an export named 'parse'.
Trying to import the module using CommonJS `require()` syntax or an incorrect named import in an ESM context.
fix
Update your import statement to `import { parse } from 'error-stack-parser-es'` and ensure your environment supports ES Modules.
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
19 hits · last 30 days
node
16
OpenAI (training)
2
Resources
error-stack-parser-es — npm install error-stack-parser-es · libregistry