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.
npm install stack-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing the current execution stack using `stack-parser` and applying various formatting options for the stack frame objects, including the `here()` convenience method.
Consider using actively maintained alternatives such as `error-stack-parser` or `stack-trace` for robust error stack parsing.
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.For TypeScript projects, you'll need to create a `declarations.d.ts` file or explicitly cast the import: `const stackParser: any = require('stack-parser');`.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.
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; /* ... */ });`.Run `npm install stack-parser` or `yarn add stack-parser` in your project directory.
Create a `declarations.d.ts` file with `declare module 'stack-parser';` or explicitly cast the import: `const stackParser: any = require('stack-parser');`.No dependency data recorded yet.