Nest: Debugging in VSCode not working

Created on 9 Feb 2019  路  9Comments  路  Source: nestjs/nest

I'm submitting a issue with VSCode debugging in windows 10

Current behavior

Running npm run start:debug is not debugging application in VSCode with Auto Attach: On. npm run start:debug command not even running the application. Please see attached image
image

Expected behavior

Running npm run start:debug debugs the application in VSCode with Auto Attach: On

Minimal reproduction of the problem with instructions

Your repo https://github.com/nestjs/typescript-starter not working in windows 10

What is the motivation / use case for changing the behavior?

Debugging is really important for any application.

Environment


Nest version: 5.8.0

For Tooling issues:

  • Node version: v9.11.1
  • Platform: Windows

Others:
VSCode version :1.31.0

Most helpful comment

Here is my configuration in launch.json, hope it can help

{
      "name": "Launch app",
      "type": "node",
      "request": "launch",
      "args": [
        "src/main.ts"
      ],
      "runtimeArgs": [
        "-r",
        "ts-node/register",
        "-r",
        "tsconfig-paths/register"
      ],
      "cwd": "${workspaceRoot}",
      "protocol": "inspector",
      "internalConsoleOptions": "openOnSessionStart",
      "env": {
        "NODE_ENV": "local",
        "NODE_PORT": "9000"
      },
      "sourceMaps": true,
      "console": "internalConsole",
      "outputCapture": "std"
    }

All 9 comments

Here is my configuration in launch.json, hope it can help

{
      "name": "Launch app",
      "type": "node",
      "request": "launch",
      "args": [
        "src/main.ts"
      ],
      "runtimeArgs": [
        "-r",
        "ts-node/register",
        "-r",
        "tsconfig-paths/register"
      ],
      "cwd": "${workspaceRoot}",
      "protocol": "inspector",
      "internalConsoleOptions": "openOnSessionStart",
      "env": {
        "NODE_ENV": "local",
        "NODE_PORT": "9000"
      },
      "sourceMaps": true,
      "console": "internalConsole",
      "outputCapture": "std"
    }

@atul221282 You can ignore tsconfig-paths if you dont use path mapping in your project. In my project, I can setup debug for main app, unit test, e2e test. From my understanding, it is better that you dont use nodemon when setup debugging.

@immanuel192 Thanks for providing the another solution, I will definitely try. However this issue is still need a fix :)

@atul221282 You can ignore tsconfig-paths if you dont use path mapping in your project. In my project, I can setup debug for main app, unit test, e2e test. From my understanding, it is better that you dont use nodemon when setup debugging.

I copied your config file and then started debugging from visual studio but it not launching the app. Can you please explain in few dot points the step that I need to take after adding the launch.json file

@atul221282 There was an issue opened for this in the VSCode repository. This issue has since been closed in favor of another one, marking the former as a duplicate. Hopefully, this is the same issue you're experiencing.

@skreborn No this is not same as that one, I am saying running npm run start:debug with Auto Attach On should run the application in debug mode but it not happening. There are other issues as well but I want to keep this simple and see what is the actual problem

@atul221282 You can ignore tsconfig-paths if you dont use path mapping in your project. In my project, I can setup debug for main app, unit test, e2e test. From my understanding, it is better that you dont use nodemon when setup debugging.

I tried your script and got debugging to work but whenever I make any change to file and refresh browser I don't see my change in browser. I have to restart the app and run the debug again. Is it expected behavior coz I think that is not right?

Actually, debugging has nothing to do with the framework itself - it's not an issue. I'll add a tutorial on how to debug apps to the docs soon (let's track this here - https://github.com/nestjs/docs.nestjs.com/issues/217)

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings