1. 在不设置setting.json配置文件的情况下调试单个js文件
vscode@1.49
Auto Attach feature 提到在Auto Attach开启的情况下,vsode调试器会自动附加到从vscode终端启动的nodejs进程。如下:
If the Auto Attach feature is enabled, the Node debugger automatically attaches to certain Node.js processes that have been launched from VS Code's Integrated Terminal.
但是我启动了多次都没见到vscode的调试器启动,但是发现terminal有个选项,JavaScript Debug Terminal

在该terminal下运行
node main.js
即使Auto Attach:Off 的情况下,调试器也启动了。
反思下,可能是我一开始的terminal不是官网说的VS Code's Integrated Terminal.我的是git bash,换成windows自带的cmd后,在Auto Attach:On 的情况下,运行node main.js
,调试器顺利的启动。换成PowerShell也是没问题的。Auto Attach:Off就不行了。
auto attach 甚至可以在引用node_modules的js文件中进行调试,也可以F11到node_modules调试依赖的代码,当然也可以调试到node的源代码,fantastic。

网友评论