{"id":14936,"library":"stack-parser","title":"Error Stack Parser","description":"stack-parser is a minimalist utility for parsing JavaScript error stack traces within Node.js environments. It takes a raw error stack string and converts it into a structured array of objects, each representing a stack frame. The package provides methods to format these frames, including custom formatting options. As of 2026, its stable version remains `0.0.1`, initially released in 2012. This indicates the package is effectively unmaintained and has seen no significant updates or feature additions over a decade. Due to its age, it primarily targets older Node.js versions and CommonJS environments, lacking support for modern ES Modules or TypeScript definitions. While functional for basic stack parsing, developers should be aware of its abandonment and consider more actively maintained alternatives for robust, cross-environment stack parsing needs.","status":"abandoned","version":"0.0.1","language":"javascript","source_language":"en","source_url":"git://github.com/scaryzet/node-stack-parser","tags":["javascript"],"install":[{"cmd":"npm install stack-parser","lang":"bash","label":"npm"},{"cmd":"yarn add stack-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add stack-parser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is a CommonJS module from 2012. It does not export an ES module API, and direct `import` statements will fail. Use `require()` for compatibility.","wrong":"import stackParser from 'stack-parser';","symbol":"stackParser","correct":"const stackParser = require('stack-parser');"},{"note":"The `parse` function is a method on the default export object. There are no named exports from this CommonJS module.","wrong":"import { parse } from 'stack-parser';","symbol":"parse","correct":"const stackParser = require('stack-parser');\nconst items = stackParser.parse((new Error).stack);"},{"note":"The `here` function is a convenience method on the default export, equivalent to `stackParser.parse((new Error).stack)`.","symbol":"here","correct":"const stackParser = require('stack-parser');\nconst items = stackParser.here();"}],"quickstart":{"code":"const stackParser = require('stack-parser');\n\n// Parse the current error stack\nconst items = stackParser.parse((new Error).stack);\n\nconsole.log('--- Default Formatting ---');\nitems.forEach(function(item) {\n\tconsole.log(item.format());\n});\n\nconsole.log('\\n--- Custom Formatting (long) ---');\nitems.forEach(function(item) {\n\tconsole.log(item.format('%what (%file, line: %line, column: %column)'));\n});\n\nconsole.log('\\n--- Custom Formatting (short) ---');\nitems.forEach(function(item) {\n\tconsole.log(item.format('%w (%f, line: %l, column: %c)'));\n});\n\nconsole.log('\\n--- Using .here() for current stack ---');\nconst currentStackItems = stackParser.here();\ncurrentStackItems.forEach(function(item) {\n\tconsole.log(item.format());\n});","lang":"javascript","description":"Demonstrates parsing the current execution stack using `stack-parser` and applying various formatting options for the stack frame objects, including the `here()` convenience method."},"warnings":[{"fix":"Consider using actively maintained alternatives such as `error-stack-parser` or `stack-trace` for robust error stack parsing.","message":"This package is effectively abandoned, with its last release (v0.0.1) dating back to 2012. It is not maintained and may not be compatible with modern Node.js features or JavaScript syntax.","severity":"deprecated","affected_versions":"0.0.1"},{"fix":"If used in an ESM environment, you must use a dynamic `import()` or wrap the `require()` call if your bundler supports it. E.g., `const stackParser = await import('stack-parser');` or ensure your project explicitly uses CommonJS.","message":"The package is a CommonJS module and does not provide an ES Module (ESM) export. Attempting to `import` it directly in an ESM context will result in a runtime error.","severity":"gotcha","affected_versions":"0.0.1"},{"fix":"For TypeScript projects, you'll need to create a `declarations.d.ts` file or explicitly cast the import: `const stackParser: any = require('stack-parser');`.","message":"There are no TypeScript type definitions available for this package. Using it in a TypeScript project will result in type errors unless explicit `any` types are used or custom declaration files are created.","severity":"gotcha","affected_versions":"0.0.1"},{"fix":"Thoroughly test its parsing capabilities with your target environment's stack traces. For maximum compatibility and robustness, use a modern, actively maintained stack parser library.","message":"The parser's robustness against different JavaScript engine stack trace formats (e.g., V8, SpiderMonkey, Chakra) or varying Node.js versions is unknown and likely limited given its age and lack of updates. Modern environments might produce stack formats it cannot fully parse.","severity":"gotcha","affected_versions":"0.0.1"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure your file is a CommonJS module (e.g., by using `.cjs` extension or setting `\"type\": \"commonjs\"` in package.json) or use dynamic import `import('stack-parser').then(module => { const stackParser = module.default || module; /* ... */ });`.","cause":"Attempting to use `require('stack-parser')` in an ES Module (ESM) context without proper transpilation or dynamic import.","error":"ReferenceError: require is not defined"},{"fix":"Run `npm install stack-parser` or `yarn add stack-parser` in your project directory.","cause":"The `stack-parser` package has not been installed or is not resolvable in the current Node.js environment.","error":"Error: Cannot find module 'stack-parser'"},{"fix":"Create a `declarations.d.ts` file with `declare module 'stack-parser';` or explicitly cast the import: `const stackParser: any = require('stack-parser');`.","cause":"TypeScript compilation error due to lack of type definitions for the `stack-parser` package.","error":"Property 'parse' does not exist on type 'typeof import(\"/path/to/node_modules/stack-parser/index\")'."}],"ecosystem":"npm"}