Andrew Kim Andrew Kim - 7 months ago 16
Ruby Question

debugger for node not working

This is probably something really simple but scouring the web for a nodeJS replacement for ruby's

binding.pry


I have the following
testDebugger.js
:

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


Then I run the following in the terminal:

$ node debug testDebugger.js


I type in x and get
ReferenceError: x is not defined


Heres the entire sequence:

$ 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


any ideas? Really love
binding.pry
in my rails apps and i hate being relegated to millions of
console.log()
's

Answer

In order to inspect variables You could switch into repl mode.

Also note that debugger has stopped at the first line, so x is not declared yet.

debug> cont
debug> repl
> x
10