2016-04-25 68 views
0

这可能是很简单的东西,但网上淘了的NodeJS替代Ruby的binding.pry调试器节点不工作

我有以下testDebugger.js

var x = 10; 
debugger; 
var y = 5; 

然后我运行在终端以下:

$ node debug testDebugger.js 

我在X形,并得到ReferenceError: x is not defined

继承人的整个序列:

$ node debug app.js 
< Debugger listening on port 5858 
debug> . ok 
break in app.js:1 
> 1 var x = 10; 
    2 debugger; 
    3 var y = 5; 
debug> x 
repl:1 
x 
^ 
ReferenceError: x is not defined 

什么想法?真的爱binding.pry在我的rails应用程序,我讨厌被降级到数百万console.log()

回答

1

为了检查变量您可以切换到repl模式。

另请注意,调试器已停在第一行,因此x尚未声明。

debug> cont 
debug> repl 
> x 
10 
+0

你好!感谢刺激,我必须键入repl ....但总比没有好。 –

+0

[node-inspector](https://github.com/node-inspector/node-inspector)可能对您更方便。 –