我正在尝试熟悉使用
node inspect
命令。我写的是简单的剧本
use_debugger.js
定义函数并调用它:
function count(nums, maxes) {
debugger;
return maxes;
}
count([1, 2, 3], [4, 5]);
当我跳入调试器时,我希望
nums
被定义并有价值
[1, 2, 3]
node inspect use_debugger.js
c
和
努姆斯
Kurts-MacBook-Pro:Scratch kurtpeek$ node --inspect-brk use_debugger.js
Debugger listening on ws://127.0.0.1:9229/7adfaada-c939-44a3-9150-6d1326b8c7d0
For help, see: https://nodejs.org/en/docs/inspector
^C
Kurts-MacBook-Pro:Scratch kurtpeek$ node inspect use_debugger.js
< Debugger listening on ws://127.0.0.1:9229/54fb6a12-82c8-4454-8307-6d120b0c26e8
< For help, see: https://nodejs.org/en/docs/inspector
< Debugger attached.
Break on start in use_debugger.js:1
> 1 (function (exports, require, module, __filename, __dirname) { function count(nums, maxes) {
2 debugger;
3 return maxes;
debug> c
break in use_debugger.js:2
1 (function (exports, require, module, __filename, __dirname) { function count(nums, maxes) {
> 2 debugger;
3 return maxes;
4 }
debug> maxes
repl:1
maxes
^
ReferenceError: maxes is not defined
at repl:1:1
at Script.runInContext (vm.js:101:20)
at Object.runInContext (vm.js:279:6)
at REPLServer.controlEval (internal/deps/node-inspect/lib/internal/inspect_repl.js:521:25)
at bound (domain.js:396:14)
at REPLServer.runBound [as eval] (domain.js:409:12)
at REPLServer.onLine (repl.js:621:10)
at REPLServer.emit (events.js:182:13)
at REPLServer.EventEmitter.emit (domain.js:442:20)
at REPLServer.Interface._onLine (readline.js:290:10)
debug>
和
maxes
estus'
答案是
exec maxes
debug> exec maxes
[ 4, 5 ]
如中所述
https://nodejs.org/api/debugger.html#debugger_information
,的
exec expr