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 fromnode_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