首页 文章

使用Visual Studio Code调试节点js

提问于
浏览
8

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

表达myExpressApp cd myExpressApp npm install npm start我的文件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中完美运行 . )

2 回答

  • 1

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

  • 3

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

    要转到"debugging"视图,您可以单击左侧的"bug"图标或按 Ctrl + Shift + D .

    您在 Call Stack 窗口中看到 Paused on breakpoint. . 该窗口包含callstack,您可以双击不同的帧以浏览相应的源 .

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

    VS Code中调试中较常用的功能部分之一是调试控制台 . 在调试视图中,'s a little icon right next to the configuration that you'使用它看起来像CLI字符 . 您可以单击该按钮或仅为 Debug: open Console 执行命令选项板搜索( Ctrl + Shift + P ) . 这将打开您的临时调试命令的调试控制台 .

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

相关问题