How to print a stack trace in Node.js?

Solution 1:

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

Solution 2:

Now there's a dedicated function on console for that:

console.trace()