nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
67.69k stars 7.63k forks source link

Debugging in VSCode not working #1543

Closed atul221282 closed 5 years ago

atul221282 commented 5 years ago

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            
immanuel192 commented 5 years ago

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"
    }
immanuel192 commented 5 years ago

@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.

atul221282 commented 5 years ago

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

atul221282 commented 5 years ago

@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

skreborn commented 5 years ago

@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.

atul221282 commented 5 years ago

@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 commented 5 years ago

@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?

kamilmysliwiec commented 5 years ago

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)

lock[bot] commented 5 years ago

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.