The property is lazy-loaded and as such does not harm the performance of your production code. However generating the JSON stack trace can take a while (not very long, but it is looking up files synchronously, if not already cached).

Since the module use stack-chain to do the stack trace magic, you can use it together with other modules that provides stack trace features. For example you can use it with trace, which gives you a nice long stack trace in asynchronous code (mainly when debugging):

require('stack-json');

require('trace');// load it after this module

setTimeout(function(){

try{

explode;

}catch(error){

console.log(error.stackJSON);

}

},100);

You can create your own formatted stack traces. This is the technique that stack-formatted use. Here is a short example:

functionformat(stack){

return stack.frames.map(function(frame){

return''+ frame.pkg.name+

''+ frame.filename+':'+ frame.line +

''+(frame.functionName ||'(anon)');

}).join('\n');

}

console.log(format(newError().stackJSON));

The package information in each stack frame (the pkg property) is gathered using the package-lookup module.