简体   繁体   English

如何调试节点模块?

[英]How can I debug node modules?

I am looking into getting involved with the rather exciting node.js, but I'm trying to find ways to replace my current development environment.我正在考虑参与相当令人兴奋的 node.js,但我正在尝试寻找替代我当前开发环境的方法。

At present, my best friend in PHPLand is FirePHP module for Firebug, which is a god send as far as debugging your PHP goes.目前,我在 PHPLand 中最好的朋友是 Firebug 的 FirePHP 模块,就调试您的 PHP 而言,这是一个神器。 What methods do I have at my disposal for debugging node code?我可以使用哪些方法来调试节点代码? Does it output errors and warnings like PHP can be set to?是否可以将 output 错误和警告如 PHP 设置为?

There are multiple ways to debug node.有多种调试节点的方法。

Personally I use a lot of well place console.log , console.dir and util.inspect statements throughout my code and follow the logic that way.就我个人而言,我在整个代码中使用了很多合适的console.logconsole.dirutil.inspect语句,并以此方式遵循逻辑。

Of course unit tests come hand in hand with debugging.当然,单元测试与调试齐头并进。 Write tests that assert your code work.编写断言您的代码工作的测试。 The unit tests will cover catching most of the bugs.单元测试将涵盖捕获大多数错误。

You must write unit tests for your node.js code.必须为 node.js 代码编写单元测试。 nodeunit is great for general testing. nodeunit非常适合一般测试。

If your using express as your web engine then use expresso如果您使用 express 作为 web 引擎,请使用expresso

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM