使用节点的内置调试器检查变量? [英] Inspecting variables using node's built-in debugger?

查看:105
本文介绍了使用节点的内置调试器检查变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用节点调试器。
我正在运行节点调试服务器来运行我的服务器。然后我有:

I am trying to use the node debugger. I am running node debug server to run my server. Then I have:

...
var Workspace = mongoose.model('Workspace');
debugger;

在这一点上,正如预期的那样,当我运行这段代码时,会弹出调试器。
但是,我希望它能够设置所有当前的变量,就像在Chrome自己的调试器中一样。

At this point, as expected, when I run this code the debugger pops up. However, I would expect it to have all of the current variables set, like it happens in Chrome's own debugger.

但是:

break in hotplate/node_modules/bd/lib/bd.js:133
132 
133   debugger;
134 
135   // Delete the ID and the version since there's no point,
debug> Workspace
ReferenceError: Workspace is not defined

所以...我如何实际上检查当前变量?

So... how do I actually inspect the current variables?

奖金问题:是否有任何方式使用Chrome的开发人员工具(CTRL-J),以便连接到节点和这样做? (我知道节点检查器,但是它是非常过时的...)

Bonus question: is there ANY way to use Chrome's developers tools (CTRL-J) so that it connects to the node and works that way? (I am aware of node-inspector, but it's very outdated and...)

推荐答案

使用复制命令(请参阅文档中的第三个示例)

Use repl command ( see third example in docs )

break in hotplate/node_modules/bd/lib/bd.js:133
132 
133   debugger;
134 
135   // Delete the ID and the version since there's no point,
debug> repl
Press Ctrl + C to leave debug repl
> Workspace

更新:奖金问题 - https://github.com/c4milo/node-webkit-agent

Update: bonus question - https://github.com/c4milo/node-webkit-agent

这篇关于使用节点的内置调试器检查变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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