如何在Visual Studio代码中调试客户端?

问题描述:

根据Microsoft Documentation,Visual Studio代码调试器应该能够调试打字稿和javascript。如何在Visual Studio代码中调试客户端?

问题在于,它们仅提供使用节点或python的服务器端应用程序示例。智能感知只建议服务器语言。

是否可以使用Visual Studio代码调试器调试客户端打字稿或JavaScript应用程序?

launch.json

{ 
    // Use IntelliSense to learn about possible Node.js debug attributes. 
    // Hover to view descriptions of existing attributes. 
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 
    "version": "0.2.0", 
    "configurations": [ 

     { 
      "type":"node"  <-- what if I'm building a JS/TS app? 
      "request": "launch", 
      "name": "Launch Program", 
      "program": "${file}", 
      "outFiles": [ 
       "${workspaceRoot}/out/**/*.js" 
      ] 
     } 
    ] 
} 
+0

查看我的答案在这里https://stackoverflow.com/questions/40045078/vscode-gulp-grunt-script-running-vscode-chrome-debugger-extension/40096464#40096464使用铬调试器扩展。 – Mark

您必须安装浏览器的调试器扩展的一个(或多个):ChromeFirefoxiOS WebEdge

然后你可以使用启动配置这样的Chrome浏览器:

{ 
    "type": "chrome", 
    "request": "launch", 
    "name": "Launch Chrome", 
    "url": "http://localhost:8080", 
    "webRoot": "${workspaceRoot}" 
} 

根据您建立工作流程,你可能必须做一些额外的步骤获得源映射到工作。

+0

谢谢!太棒了! – Kokodoko