Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
469 views
in Technique[技术] by (71.8m points)

node.js - Inspecting variables using node's built-in debugger?

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;

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.

But:

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?

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...)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...