{"id":13127,"library":"error-stack-parser","title":"Error Stack Parser","description":"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.","status":"active","version":"2.1.4","language":"javascript","source_language":"en","source_url":"git://github.com/stacktracejs/error-stack-parser","tags":["javascript","stacktrace","error","stack","parser","typescript"],"install":[{"cmd":"npm install error-stack-parser","lang":"bash","label":"npm"},{"cmd":"yarn add error-stack-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add error-stack-parser","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides the structured StackFrame objects that error-stack-parser generates. Updated to v1.x in error-stack-parser v2.0.0.","package":"stackframe","optional":false}],"imports":[{"note":"While error-stack-parser exports a CommonJS module (`module.exports = ErrorStackParser`), modern bundlers and TypeScript with `esModuleInterop` enabled will allow this default import syntax. Without `esModuleInterop`, you might need `import * as ErrorStackParser from 'error-stack-parser';` or explicit CommonJS `require`.","wrong":"import { ErrorStackParser } from 'error-stack-parser';","symbol":"ErrorStackParser","correct":"import ErrorStackParser from 'error-stack-parser';"},{"note":"For Node.js environments using CommonJS modules.","symbol":"ErrorStackParser (CommonJS)","correct":"const ErrorStackParser = require('error-stack-parser');"},{"note":"The `StackFrame` type is re-exported directly from `error-stack-parser` for convenience and backward compatibility since v2.1.0, though its definition originates from the `stackframe` package.","wrong":"import { StackFrame } from 'stackframe';","symbol":"StackFrame (Type)","correct":"import type { StackFrame } from 'error-stack-parser';"}],"quickstart":{"code":"import ErrorStackParser from 'error-stack-parser';\n\nfunction thirdFunction() {\n  try {\n    throw new Error('This is a test error!');\n  } catch (error) {\n    if (error instanceof Error) {\n      console.log('Parsing error stack...');\n      const frames = ErrorStackParser.parse(error);\n      console.log(`Found ${frames.length} stack frames.`);\n      frames.forEach((frame, index) => {\n        console.log(`\\n--- Frame ${index + 1} ---`);\n        console.log(`Function: ${frame.functionName || '<anonymous>'}`);\n        console.log(`File: ${frame.fileName || '<unknown>'}:${frame.lineNumber || '?'}:${frame.columnNumber || '?'}`);\n        if (frame.isNative) console.log('  (Native Code)');\n        if (frame.isEval) console.log(`  (Eval Code from ${frame.evalOrigin})`);\n      });\n    } else {\n      console.error('Caught something that is not an Error object.');\n    }\n  }\n}\n\nfunction secondFunction() {\n  thirdFunction();\n}\n\nfunction firstFunction() {\n  secondFunction();\n}\n\nfirstFunction();","lang":"typescript","description":"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."},"warnings":[{"fix":"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`).","message":"The `stackframe` dependency was updated to v1.x, which changed how `StackFrame` objects are constructed and accessed. Code directly interacting with `StackFrame` internals or expecting specific properties/methods from `stackframe` v0.x will break.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"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.","message":"Parsing limitations exist for older browsers. `Error` objects in IE9 and earlier lack sufficient stack information for meaningful parsing. IE10 only provides a `stack` property after an error is explicitly `throw`n.","severity":"gotcha","affected_versions":"<=1.0.0"},{"fix":"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.","message":"In v1.3.0, the handling of anonymous functions and 'new Constructor' calls was improved, removing previous attempts to normalize cross-browser representations. While an improvement, this might subtly change the parsed `functionName` for some anonymous functions compared to earlier versions.","severity":"gotcha","affected_versions":">=1.3.0"}],"env_vars":null,"search_vec":"'2.1.4':74 'abstract':115 'access':54 'across':109 'array':33 'away':116 'browser':12,111 'bug':90 'cadenc':79 'call':58 'column':48 'contain':38 'cross':11 'cross-brows':10 'crucial':62 'current':70 'debug':67 'depend':93 'design':15 'detail':39 'differenti':97 'environ':114 'error':1,4,22,64,125 'error.stack':121 'explicit':82 'extract':17 'file':43 'fix':91 'focus':100 'format':122 'function':41 'inconsist':118 'inform':19 'isn':80 'javascript':13,21,123 'key':96 'librari':14 'lightweight':9 'like':40 'line':45 'maintain':86 'manag':94 'name':42 'nativ':120 'node.js':113 'number':46,49 'object':23,36,108 'output':106 'pars':27 'parser':3,6,127 'programmat':53 'project':85 'properti':25 'provid':51,102 'raw':28 'regular':87 'releas':78 'report':65 'represent':55 'stabl':71 'stack':2,5,24,29,59,126 'stackfram':35,107 'stacktrac':124 'standard':104 'state':83 'strict':77 'structur':18,105 'tool':68 'trace':30 'typescript':128 'updat':88 'url':44 'various':110 'version':72","created_at":"2026-04-20T01:52:53.439733+00:00","updated_at":"2026-04-20T01:52:53.439733+00:00","problems":[{"fix":"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');`.","cause":"Incorrect import statement (e.g., named import for a default-exported CommonJS module) or attempting to call `parse` directly on the module object without accessing the `ErrorStackParser` class.","error":"TypeError: ErrorStackParser.parse is not a function"},{"fix":"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.","cause":"Attempting to access properties or methods of `StackFrame` objects that were removed or renamed in `stackframe` v1.x (and thus `error-stack-parser` v2.x).","error":"Property 'someOldStackFrameProperty' does not exist on type 'StackFrame'."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":"https://www.stacktracejs.com","github":"https://github.com/stacktracejs/error-stack-parser","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/error-stack-parser","openapi_spec":null,"status_page":null,"smithery":null,"categories":["observability","testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}