admin管理员组文章数量:1327750
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 remend debugger tool on node.js
Thanks
sample.js
// 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;
dbmand({
listCollections: 1
}, function(err, o) {
debugger;
return print(o["cursor"]);
});
});
}).call(this);
exception
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)
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 remend debugger tool on node.js
Thanks
sample.js
// 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.mand({
listCollections: 1
}, function(err, o) {
debugger;
return print(o["cursor"]);
});
});
}).call(this);
exception
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)
Share
Improve this question
asked Jul 15, 2015 at 2:31
newBikenewBike
15k29 gold badges117 silver badges204 bronze badges
3 Answers
Reset to default 22022 update
You can use node inspect
badloop.js:
let orders = [341, 454, 198, 264, 307];
let totalOrders = 0;
for (let i = 0; i <= orders.length; i++) {
debugger; //Breakpoint
totalOrders += orders[I];
}
console.log(totalOrders);
node inspect badloop.js
c
or cont
: Continue execution to the next breakpoint or to the end of the program.
n
or next
: Move to the next line of code.
s
or step
: Step into a function
o
: Step out of a function
you can use the help
mand inside de debugger to see all available mands.
You're probably looking for the "repl" mand in the mand-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
You might want to try CodeLite IDE (a free, cross platform, open source IDE). Since version 8.1 we fully support debugging Node.js applications
本文标签:
版权声明:本文标题:javascript - How could I debug in nodejs, any tool similar to pdb or pry in Ruby or Python - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742232368a2437453.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论