{"id":13126,"library":"error-stack-parser-es","title":"Cross-browser Error Stack Parser (ESM)","description":"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.","status":"active","version":"1.0.5","language":"javascript","source_language":"en","source_url":"https://github.com/antfu/error-stack-parser-es","tags":["javascript","typescript"],"install":[{"cmd":"npm install error-stack-parser-es","lang":"bash","label":"npm"},{"cmd":"yarn add error-stack-parser-es","lang":"bash","label":"yarn"},{"cmd":"pnpm add error-stack-parser-es","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is ESM-first and ships TypeScript types. Use named imports.","wrong":"const { parse } = require('error-stack-parser-es')","symbol":"parse","correct":"import { parse } from 'error-stack-parser-es'"},{"note":"The 'lite' version offers a simplified stack frame structure (e.g., `line`, `col`) and can be imported from a subpath.","wrong":"import parseLite from 'error-stack-parser-es/lite'","symbol":"parse","correct":"import { parse } from 'error-stack-parser-es/lite'"},{"note":"Available only in the 'lite' version, this function allows parsing raw stacktrace strings directly. It does not support Opera's stacktrace format.","symbol":"parseStack","correct":"import { parseStack } from 'error-stack-parser-es/lite'"}],"quickstart":{"code":"import { parse } from 'error-stack-parser-es';\nimport { parse as parseLite, parseStack } from 'error-stack-parser-es/lite';\n\nfunction simulateError() {\n  try {\n    throw new Error('This is a test error to demonstrate stack parsing!');\n  } catch (err) {\n    return err;\n  }\n}\n\nconst errorInstance = simulateError();\n\n// Using the standard API\nconst standardStackFrames = parse(errorInstance);\nconsole.log('Standard Stack Frames:', standardStackFrames[0].fileName, standardStackFrames[0].lineNumber);\n\n// Using the Lite API for simplified frames\nconst liteStackFrames = parseLite(errorInstance);\nconsole.log('Lite Stack Frames:', liteStackFrames[0].file, liteStackFrames[0].line);\n\n// Parsing a raw stack string with the Lite API\nconst rawStackString = 'Error\\n    at myFunction (bundle.js:10:5)\\n    at anotherFunc (main.js:20:10)';\nconst parsedFromString = parseStack(rawStackString);\nconsole.log('Parsed from string:', parsedFromString[0].name, parsedFromString[0].col);","lang":"typescript","description":"Demonstrates parsing an `Error` object using both the standard and 'lite' APIs, and parsing a raw stack string with the 'lite' API."},"warnings":[{"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.","message":"The 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.","severity":"breaking","affected_versions":">=1.0.5"},{"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`.","message":"The `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.","severity":"gotcha","affected_versions":">=0.1.3"},{"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.","message":"This 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.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure the input to `parse` or `parseStack` is a valid `Error` instance or a non-empty string representing a stack trace.","cause":"Attempting to parse an invalid or `null`/`undefined` Error object or stack string.","error":"TypeError: Cannot read properties of undefined (reading 'split')"},{"fix":"Update your import statement to `import { parse } from 'error-stack-parser-es'` and ensure your environment supports ES Modules.","cause":"Trying to import the module using CommonJS `require()` syntax or an incorrect named import in an ESM context.","error":"SyntaxError: Named export 'parse' not found. The requested module 'error-stack-parser-es' does not provide an export named 'parse'."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}