假设我有一个nodejs应用,运行在AWS - 亚马逊云平台上(Amazone Web Service)。我想用本地的Visual Studio Code来远程调试服务器端的nodejs应用。
Visual Studio Code的调试配置里定义了两种类型,attach和launch。Visual Studio Code的官方文档对这两种调试启动行为的解释:
The best way to explain the difference between launch and attach is think of a launch configuration as a recipe for how to start your app in debug mode before VS Code attaches to it,
Launch的意思简而言之就是以debug模式启动app。
while an attachconfiguration is a recipe for how to connect VS Code's debugger to an app or process that's alreadyrunning.
而Attach的含义是将Visual Studio Code的调试器绑定到一个已经处于运行状态的应用。
因为我的需求是用本地的Visual Studio Code去调试AWS上正在运行的nodejs应用,毫无疑问应该选Attach。
点击debug configuration这个按钮:
![d838fde606b65035264fb39ff6b3df14.png](https://i-blog.csdnimg.cn/blog_migrate/8f60202058ee8d5fcf88002fa9350a49.jpeg)
自动弹出存放调试配置信息的launch.json文件了:
![021c697563e3b82ecd760bbf394b7681.png](https://i-blog.csdnimg.cn/blog_migrate/f353bb4bd475a5723b40b143c04f4c62.jpeg)
把launch.json的内容替换成下面的内容:
```Json
{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0