开发者

How do I see Node.js errors?

开发者 https://www.devze.com 2023-01-04 20:26 出处:网络
I\'m new to Node.js.I know there are more involved debuggers available (like node_debug and ndb), but is there a simple way to see runtime errors thrown in Node.js?

I'm new to Node.js. I know there are more involved debuggers available (like node_debug and ndb), but is there a simple way to see runtime errors thrown in Node.js?

With a simple example file like this:

var sys = require('sys'),
http = require("http");

var server = http.createServer(function(req, res) {
    var foo = [1, 2, 3];
    foo.append(4);
    res.writeHead(200, {'Content-Type': 'text/html'});
    res.write('Ok', 'utf-8');
    res.end();
});

server.listen(8080);

sys.puts("Server running at http://localhost:8080/");

the foo.append(4); line fails, but that err开发者_C百科or doesn't ever seem to get propagated to the console, and I don't see it in Console.app or STD_ERR either.

Is there a way to view that error?


Updating my copy of Node.js (from v0.1.95 to v0.1.99) seems to have fixed it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号