JSPM

nestjs-stack-parser

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q49196F
  • License MIT

A simple and typed parser to extract meaningful data from NestJS-style stack traces.

Package Exports

  • nestjs-stack-parser
  • nestjs-stack-parser/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (nestjs-stack-parser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

nestjs-stack-parser

A lightweight and typed utility for parsing JavaScript and NestJS stack traces into structured, readable objects.


πŸ“¦ Installation

npm install nestjs-stack-parser

πŸ” What It Does

nestjs-stack-parser helps you convert raw stack tracesβ€”like those from NestJS or plain JavaScript errorsβ€”into structured objects. It parses:

  • The error type (e.g., TypeError, ForbiddenException)
  • The error message
  • The full stack trace, broken down into:
    • Class name (if present)
    • Method name
    • File path
    • Line and column numbers

πŸ› οΈ Usage

import { parseStack } from "nestjs-stack-parser";

try {
  // some code that throws
} catch (err) {
  const parsed = parseStack(err.stack, { excludeNodeModules: true });
  console.log(parsed);
}

Example Output

{
  type: 'TypeError',
  error: "Cannot read properties of undefined (reading 'qd')",
  stack: [
    {
      at: 'AppService.getHello',
      className: 'AppService',
      methodName: 'getHello',
      file: '/app/src/app.service.ts',
      line: 13,
      column: 20
    },
    // ...more frames
  ]
}

βš™οΈ Options

excludeNodeModules

  • Type: boolean
  • Default: false
  • If true, stack frames from node_modules will be excluded.

πŸ§ͺ Testing

This project uses Jest for unit tests. To run tests:

npm test

πŸ“ Project Structure

β”œβ”€β”€ src/
β”‚   └── parseStack.ts
β”œβ”€β”€ dist/
β”œβ”€β”€ test/
β”‚   └── parseStack.test.ts
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ jest.config.js
└── README.md

πŸ“„ License

MIT Β© Nicolas LEROY