gpt4 book ai didi

javascript - Node 调试器不工作

转载 作者:行者123 更新时间:2023-12-03 07:05:16 24 4
gpt4 key购买 nike

这可能是非常简单的事情,但是在网络上搜索 ruby​​ 的 binding.pry 的 NodeJS 替代品

我有以下testDebugger.js:

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

然后我在终端中运行以下命令:

$ node debug testDebugger.js

我输入x并得到ReferenceError:x未定义

这是整个序列:

$ 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

有什么想法吗?我真的很喜欢 Rails 应用中的 binding.pry,但我讨厌被降级到数百万个 console.log()

最佳答案

为了检查变量,您可以切换到 repl 模式。

另请注意,调试器已在第一行停止,因此尚未声明 x

debug> cont
debug> repl
> x
10

关于javascript - Node 调试器不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36849752/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com