How can I get error reporting in Node? I am running v0.6.15 (used simple osx install DMG) and whenever there is an error, say I try to use a undefined variable, the process just stops with no indication as to why.
I guess im looking for the node version of PHP's error_reporting(E_ALL);
Any suggestions?
==EDIT==
Weird... Ok... So I noticed that I gets errors just fine in the file I run, but not in the ones I "require"
The file I am running simply has this code
process.on('uncaughtException', function(err) {
console.log(err);
});
var ImageProcessor = require('./ImageProcessor').ImageProcessor;
var imageProcessor = new ImageProcessor();
imageProcessor.imageRequestEnd();
The imageProcessor is a mootools class if that matters but isnt using anything else that special.
While I agree with @Brad that I've never seen such behavior, in general, if you're debugging a NodeJS program and want to know what's causing it to be killed, you can use a construct like this:
process.on('uncaughtException', function(err) {
console.log(err);
});
in your script.
Note that many people argue that you shouldn't use such a construct in production, since an uncaught exception often indicates that you've encountered an error so severe and unexpected that the only way to recover is to restart. This might or might not be true for your particular application; in any case, this can be useful to debug with.
However, like @Brad indicates, the most likely reason why you're not seeing anything is that console output is being redirected somehow. Try running without using "forever", "supervisor", "screen", or whatever other process wrapper you're using.