I am developing a Nest.js server and would like to be able to print useful stack trace in console (e.g. console.log). By default, it returns a reference to the line number in the compiled sources (.js). This is not useful for debugging as it's missing the reference to the line number in the original source files (.ts)
Here is my tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./dist",
"_baseUrl": "./",
"incremental": true
},
"exclude": ["node_modules", "dist"]
}
The .map files are generated in the dist folder as well, though it seems to be of no use when checking stack traces in the console.
tsand that's because the server is webpacked via thengcompiler. Everything is injsfiles as expected cause you're running JavaScript. This is the default behavior, but it looks like this comment shows a way to get ts lines in the stack trace insteadsource-map-supportto the project, now it outputs the line number from thetsfile