【问题标题】:Debugging nestjs micro-service framework调试nestjs微服务框架
【发布时间】:2018-11-19 08:59:18
【问题描述】:

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

该框架是一个带有 springboot 约定的 typescript 项目

http://nestjs.com

【问题讨论】:

    标签: typescript visual-studio-code microservices nestjs


    【解决方案1】:

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

    .vscode 文件夹中添加 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": "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

    完成!你可以设置断点

    【讨论】:

    • 我只是运行“npn run start:debug”,我的 vs 代码会自动启动调试会话。 (我在 VS Code 设置中启用了带有标志的调试器附加)。
    【解决方案2】:

    按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。

    【讨论】:

    • 调试“Step Over”时无法正常工作(打开系统.js文件)
    猜你喜欢
    • 2020-02-04
    • 2020-05-29
    • 2021-01-12
    • 2021-09-04
    • 1970-01-01
    • 1970-01-01
    • 2011-06-16
    • 1970-01-01
    • 2012-03-02
    相关资源
    最近更新 更多