Transpiled applications, such as those written in TypeScript or Babel, will show error stack traces that typically point to files, lines, and functions within the built files, rather than the source files.
If you enable source mapping in Node.js, you'll get more meaningful error traces that point to lines and functions within the source code.
How to enable source mapping
You can enable Node's source map support in the
node command that starts your application:
node --enable-source-maps -r newrelic ./dist/server.js
An application run without source map support might display an error stack trace like this:
$Error: Failed to get all entries in model$at /dist/models/entries.js:41:23$... (multiple functions in New Relic Node agent js files)$at /dist/models/entries.js:39:35$at Generator.next (<anonymous>)
Note that the trace refers to the built files in
The same application with source map support enabled will instead reference the source code files:
$Error: Failed to get all entries in model$at <anonymous> (/src/models/entries.ts:28:13)$... (multiple functions in New Relic Node agent js files)$at <anonymous> (/src/models/entries.ts:26:19)$at Generator.next (<anonymous>)
This stack trace points to specific functions and line numbers within your source files, so you can find errors more easily.
You can observe this behavior by running our source maps example application, which makes it easy to compare error traces both with and without source maps enabled.