JavaScript python 和 nodejs 里面有没有类似 ruby 的 binding.pry 的东西?

qinix · August 25, 2013 · Last by adamshen replied at April 26, 2016 · 4852 hits

pry 真是神器啊,秒杀各种调试器。有没有人知道 python 和 nodejs 里面有没有类似的东西?

更新 1:查了 nodejs,有个 node-inspector 似乎不错,不过依赖浏览器。node 还有个 repl.start API 也不错,可以简单包装下

更新 2:又研究了 python,可以用 IPython 或者 python -i xxx.py 或者

def interact():
    import code
    code.InteractiveConsole(locals=globals()).interact()
import IPython
IPython.embed()

debugger 语句加断点。nodejs 和浏览器通用。nodejs 需要用 node debug file 启动。

#1 楼 @doitian 这样加断点的话能在 debug 时执行 nodejs 语句吗?

python 的 https://pypi.python.org/pypi/debug 好用 基于 ipdb, 只要 import 就全局生效,不用插入具体代码块

#2 楼 @qinix 在 debugger 里用命令 repl 就可以执行 js 了。浏览器的话直接 console 里就能运行 js

#4 楼 @doitian 可行,非常感谢

You need to Sign in before reply, if you don't have an account, please Sign up first.