调试nestjs微服务框架

时间:2018-06-09 14:19:08

标签: typescript visual-studio-code microservices nestjs

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

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

http://nestjs.com

2 个答案:

答案 0 :(得分:1)

按F5键,选择“节点”,将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"
        }
    ]
}

因此放一个breackpoint,然后再次击中F5。

答案 1 :(得分:0)

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

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"
    }
  ]
}

然后运行npn run start:debug

然后在vscode中选择Attach NestJs Ws

完成!您可以设置断点 enter image description here