How to print a stack trace in Node.js?


Question

Does anyone know how to print a stack trace in Node.js?

1
470
12/13/2017 4:12:58 AM

Any Error object has a stack member that traps the point at which it was constructed.

var stack = new Error().stack
console.log( stack )

or more simply:

console.trace("Here I am!")
556
3/7/2012 5:01:41 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon