Debugging nest.js application with vscode

前端 未结 10 2103
野的像风
野的像风 2021-02-01 20:24

I am testing the nest.js framework but I am struggling to run it with VSCode so that I can properly debug my code. This is pretty much the same issue as described here Running n

10条回答
  •  长发绾君心
    2021-02-01 21:02

    I tried the accepted answer and all the other variances and none worked for me, however what really works for me is to attach to the 9229 port. What I did is add/modify your launch.json with the following config

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

    and in package.json (Nest new CLI commands, requires 6.8.x, see this blog)

    {
      "name": "nest-app",
      "scripts": {
        "start:debug": "nest start --debug --watch"
      }
    }
    

    and finally it works!

提交回复
热议问题