I ran my script by
node debug sample.js
It stopped at the target position.
Somehow, I don't know how to inspect the variables.
For example, I want to print out the variable db
, but it couldn't.
Any recommend debugger tool on node.js
Thanks
// Generated by CoffeeScript 1.9.2
(function() {
var MongoClient, print;
print = require('awesome-print');
MongoClient = require('mongodb').MongoClient;
MongoClient.connect('mongodb://localhost:27017/test', function(err, db) {
debugger;
db.command({
listCollections: 1
}, function(err, o) {
debugger;
return print(o["cursor"]);
});
});
}).call(this);
20
21 });
debug> print(db)
repl:1
print(db)
^
ReferenceError: print is not defined
at repl:1:1
at Object.exports.runInContext (vm.js:64:17)
at Interface.controlEval (_debugger.js:975:21)
at bound (domain.js:254:14)
at REPLServer.runBound [as eval] (domain.js:267:12)
at REPLServer.<anonymous> (repl.js:279:12)
at REPLServer.emit (events.js:107:17)
at REPLServer.Interface._onLine (readline.js:214:10)
at REPLServer.Interface._line (readline.js:553:8)
at REPLServer.Interface._ttyWrite (readline.js:830:14)
debug> db
repl:1
db
^
ReferenceError: db is not defined
at repl:1:1
at Object.exports.runInContext (vm.js:64:17)
at Interface.controlEval (_debugger.js:975:21)
at bound (domain.js:254:14)
at REPLServer.runBound [as eval] (domain.js:267:12)
at REPLServer.<anonymous> (repl.js:279:12)
at REPLServer.emit (events.js:107:17)
at REPLServer.Interface._onLine (readline.js:214:10)
You're probably looking for the "repl" command in the command-line debugger. Also node-inspector is a great way to hook up chrome's awesome devtools to a node process. You can learn how to use node-inspector in my blog post: Lighting up your javascript with the debugger
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With