使用Visual Studio Code调试节点js

问题描述 投票:10回答:2

我尝试使用Visual Studio Code在节点JS中调试项目,但我没有实现。我用下一个命令构建了一个简单的项目:

表达myExpressApp cd myExpressApp npm安装 asl开始

我的文件launch.json:

enter image description here

我在Window“Debug”中选择选项“Launch app.js”。应用程序运行没有问题。我提出了一个断点:

enter image description here

我在Chrome中给出了地址:http://localhost:3000/

Visual Studio Code说:“在断点暂停”,但我没有看到任何内容,我可以按继续,应用程序继续...

编辑:我使用OS X 10.10(我测试了它,它在Ubuntu中完美运行。)

node.js express debugging visual-studio-code
2个回答
3
投票

VSCode 0.8.0存在早于0.12.0的节点版本的问题。升级到至少0.12.0或等待即将推出的VSCode 0.9.0。


1
投票

使用Visual Studio Code进行调试时,遇到断点时可以执行许多操作。

要进入“调试”视图,您可以单击左侧的“错误”图标或点击Ctrl + Shift + D

您可以在“调用堆栈”窗口中看到Paused on breakpoint.。该窗口包含callstack,您可以双击不同的帧以浏览相应的源。

您还可以在此处看到“变量”窗口以查看变量的值(local / global / closure / etc.)。

VS Code中调试中较常用的功能部分之一是调试控制台。在调试视图中,您正在使用的配置旁边有一个小图标,看起来像CLI字符。你可以点击它,或者只是为Ctrl + Shift + P做命令调色板搜索(Debug: open Console)。这将打开您的临时调试命令的调试控制台。

The documentation on VS Code debugging is quite robust, too, so I recommend you take a look at this

© www.soinside.com 2019 - 2024. All rights reserved.