Javascript – How to print a stack trace in Node.js

javascriptnode.jsstack-trace

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

Best Solution

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!")