如何调试节点模块? [英] How can I debug node modules?

查看:102
本文介绍了如何调试节点模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑加入令人兴奋的node.js,但我正在尝试寻找方法来替换当前的开发环境。

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.

目前,在PHPLand中,我最好的朋友是Firebug的FirePHP模块,这是调试PHP的最佳选择。我有什么方法可以调试节点代码?

At present, my best friend in PHPLand is FirePHP module for Firebug, which is a god send as far as debugging your PHP goes. What methods do I have at my disposal for debugging node code? Does it output errors and warnings like PHP can be set to?

推荐答案

有多种方法可以调试节点。

There are multiple ways to debug node.

  • node debug app.js
  • node-inspector
  • console
  • util

我个人使用了很多好地方 console.log console.dir 以及整个代码中的 util.inspect 语句,并遵循这种逻辑。

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.

当然,单元测试会自动进行手调试。编写断言代码工作的测试。单元测试将涵盖捕获大多数错误。

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.

必须为node.js代码编写单元测试。 nodeunit 非常适合常规测试。

You must write unit tests for your node.js code. nodeunit is great for general testing.

如果您使用express作为网络引擎,则使用 expresso

If your using express as your web engine then use expresso

这篇关于如何调试节点模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆