4

我们如何在vscode中调试nest微服务框架,

该框架是一个带有springboot约定的打字稿项目

http://nestjs.com

4

2 回答 2

3

按 F5,选择 Node,将 launch.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",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Debug Nest Framework",
            "args": ["${workspaceFolder}/src/main.ts"],
            "runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
            "sourceMaps": true,
            "cwd": "${workspaceRoot}",
            "protocol": "inspector"
        }
    ]
}

所以放一个断点并再次按F5。

于 2018-07-11T22:44:23.033 回答
2

如果您使用的是 nestjs 6.8+(请参见此处

添加包含此内容launch.json的文件夹.vscode

{
  // 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",
  "configurations": [
    {
      "type": "node",
      "request": "attach",
      "name": "Attach NestJS WS",
      "port": 9229,
      "restart": true,
      "stopOnEntry": false,
      "protocol": "inspector",
      "skipFiles": [
         "<node_internals>/**/*.js",
         "${workspaceRoot}/node_modules/**/*.js",
       ]
    }
  ]
}

然后运行npn run start:debug

然后在 vscode 中选择Attach NestJs Ws

完毕!你可以设置断点 在此处输入图像描述

于 2020-03-09T15:03:42.050 回答