【问题标题】:Accessing outer scope variables in node debugger repl在节点调试器 repl 中访问外部范围变量
【发布时间】:2015-05-31 21:38:40
【问题描述】:
var test = "foo";
var test2 = "bar";
io.sockets.on("connection", function (socket) {
  var t = test;
  debugger;
});

我正在使用"node debug app.js" 在节点中运行上述代码。我打断点并输入repl。我希望能够访问内部和外部范围内的变量,但是在尝试显示 test2 的内容时出现 ReferenceError,因为 repl 认为它没有被定义。 test 之所以有效,是因为当我分配给 t 时,我在内部范围内显式访问它。

有没有办法运行节点调试器,以便我可以访问这些外部范围变量?

【问题讨论】:

标签: javascript node.js


【解决方案1】:

查看 node-inspector,它是一个新的和改进的 node.js 调试器,它应该让您只需要悬停一个变量来显示和编辑它的值:

http://strongloop.com/strongblog/announcing-a-new-and-improved-node-js-debugger/

https://github.com/node-inspector/node-inspector

【讨论】:

  • 使用节点检查器没有帮助。
  • 在我的专业意见中,node-inspector 是一个 POS。
【解决方案2】:

trepanjs 是一个类似 gdb 的调试器,支持 gdb 命令 updownframe

【讨论】:

    猜你喜欢
    • 2011-06-01
    • 1970-01-01
    • 2023-04-07
    • 1970-01-01
    • 1970-01-01
    • 2013-03-20
    • 2012-07-16
    • 1970-01-01
    • 2016-06-23
    相关资源
    最近更新 更多