Error Stack Parser

0.0.1 · abandoned · verified Sun Apr 19

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.

Common errors

Warnings

Install

Imports

Quickstart

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());
});

view raw JSON →