2016-04-25 59 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)可能對您更方便。 –