Registry / serialization / stack-parser

stack-parser

JSON →
library0.0.1jsnpmunverified

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-parser
INSTALL
IMPORT
SIG · STACK-PARSER
S
stack-parser
serializationjavascriptv0.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

stackParser
const stackParser = require('stack-parser');
import stackParser from 'stack-parser';
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.
parse
const stackParser = require('stack-parser'); const items = stackParser.parse((new Error).stack);
import { parse } from 'stack-parser';
The `parse` function is a method on the default export object. There are no named exports from this CommonJS module.
here
const stackParser = require('stack-parser'); const items = stackParser.here();
The `here` function is a convenience method on the default export, equivalent to `stackParser.parse((new Error).stack)`.

Demonstrates parsing the current execution stack using `stack-parser` and applying various formatting options for the stack frame objects, including the `here()` convenience method.

const stackParser = require('stack-parser'); // Parse the current error stack const items = stackParser.parse((new Error).stack); console.log('--- Default Formatting ---'); items.forEach(function(item) { console.log(item.format()); }); console.log('\n--- Custom Formatting (long) ---'); items.forEach(function(item) { console.log(item.format('%what (%file, line: %line, column: %column)')); }); console.log('\n--- Custom Formatting (short) ---'); items.forEach(function(item) { console.log(item.format('%w (%f, line: %l, column: %c)')); }); console.log('\n--- Using .here() for current stack ---'); const currentStackItems = stackParser.here(); currentStackItems.forEach(function(item) { console.log(item.format()); });
Debug
Known issues
deprecatedThis 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.
fix
Consider using actively maintained alternatives such as `error-stack-parser` or `stack-trace` for robust error stack parsing.
affects: 0.0.1
gotchaThe 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.
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.
affects: 0.0.1
gotchaThere 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.
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');`.
affects: 0.0.1
gotchaThe 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.
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.
affects: 0.0.1
Errors
Common errors & fixes
ReferenceError: require is not defined
Attempting to use `require('stack-parser')` in an ES Module (ESM) context without proper transpilation or dynamic import.
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; /* ... */ });`.
Error: Cannot find module 'stack-parser'
The `stack-parser` package has not been installed or is not resolvable in the current Node.js environment.
fix
Run `npm install stack-parser` or `yarn add stack-parser` in your project directory.
Property 'parse' does not exist on type 'typeof import("/path/to/node_modules/stack-parser/index")'.
TypeScript compilation error due to lack of type definitions for the `stack-parser` package.
fix
Create a `declarations.d.ts` file with `declare module 'stack-parser';` or explicitly cast the import: `const stackParser: any = require('stack-parser');`.
Upgrade
Version history
0.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
stack-parser — npm install stack-parser · libregistry