Error Stack Parser is a lightweight, cross-browser JavaScript library designed to extract structured information from JavaScript `Error` objects' `stack` property. It parses raw stack traces into an array of `StackFrame` objects, each containing details like function name, file URL, line number, and column number. This provides a programmatically accessible representation of the call stack, which is crucial for error reporting and debugging tools. The current stable version is 2.1.4. While a strict release cadence isn't explicitly stated, the project maintains regular updates for bug fixes and dependency management. Its key differentiator is its focus on providing a standardized, structured output (`StackFrame` objects) across various browser and Node.js environments, abstracting away the inconsistencies in native `Error.stack` formats.
npm install error-stack-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to catch an error, parse its stack trace using `ErrorStackParser.parse`, and then iterate through the resulting `StackFrame` objects to display detailed information about each call site.
Review the `stackframe` CHANGELOG for v1.x (if directly using `stackframe`) and adapt your code to the new `StackFrame` API. If only consuming `StackFrame` objects from `error-stack-parser`, ensure your code correctly accesses their properties (e.g., `fileName`, `lineNumber`).
Be aware of these limitations when targeting legacy browser environments. Consider using a polyfill or alternative error capture mechanism if detailed stack traces are critical in these browsers.
Review your error reporting and analytics if they rely on the exact `functionName` output for anonymous functions parsed by versions prior to 1.3.0.
Ensure you are importing the `ErrorStackParser` class correctly. For ESM/TypeScript, use `import ErrorStackParser from 'error-stack-parser';`. For CommonJS, use `const ErrorStackParser = require('error-stack-parser');`.Consult the `stackframe` v1.x documentation or source to verify the correct property names and methods for `StackFrame` objects. Update your code to use the current API.