Nodejs error has no traceback

I'm somewhat new to nodejs.

Using express / npm.

Once i hit '/' from my browser, I get this in output:

[TypeError: Object #<Object> has no method 'push']

No line numbers, no traceback, nothing.

I need to be able to fix this error, and to do that I need to know what file / line # this occurred.

How do I get nodejs to output a traceback?

First, add an express error handler, which is middleware expecting 4 arguments:

app.use(function (error, req, res, next) {
  console.error(error.stack);
});

Make sure to put the above code at the very end of your middleware stack after all your normal middleware and route handlers are defined.

If that doesn't get you your stack trace, catch process-level uncaught exceptions:

process.on("uncaughtException", function (error) {
  console.error(error.stack);
});

And one final tip would be run your app under the debugger with node --debug=3001 app.js, connect to it with node-inspector, open the debugger in chrome, enable "stop on exceptions", then trigger the error. The debugger will take you to the line where the exception occurs.