Giter Club home page Giter Club logo

vs-code-debugging's Introduction

Debugging all types of Node applications


Steps for debugging

  1. Initialize/Debug the applications in this order
  • js-debug
  • ts-debug
  • express-debug
  • nest-debug
  1. Go to Debugger using Ctrl + Shift + D or โŒ˜ + Shift + D

    Debugger Image
  2. Create launch.json file

    It will reside in the workspace directory under .vscodefolder with namelaunch.json

    Launch json Image
  3. Put the launch configuration inside the launch.json file and in the debugger select the configuration Launch Selection Image

  4. click on the green play button to attach the debugger


Resources

VS code editor debugging

Typescript Debugging

tsconfig.json docs


Explanation of each window:

debugger window Image

1. Variables

- it contains the local, global and closure variable present in the execution context

variable window Image

2. Watch

- Watch Window allows you to see value of variables and expressions while debugging.

3. Call Stack

- Shows the function call stack from named to anonymous function

call stack window Image

4. Loaded Scripts

- Shows the files that are currently in execution

loaded script window Image

5. Breakpoints

- Shows all the breakpoints that you've given in all the files in the workspace

breakpoint window Image


Each configuration for launch.json for respective file/frameworks

  1. Debugging JS Application
    {
      "type": "pwa-node",
      "request": "launch",
      "name": "JS-Launch",
      "skipFiles": ["<node_internals>/**"],
      "program": "${workspaceFolder}/js-debug/index.js",
      "outFiles": ["${workspaceFolder}/**/*.js"]
    },
  1. Debugging TS Application
    {
      "type": "pwa-node",
      "request": "launch",
      "name": "TS-Launch",
      "skipFiles": ["<node_internals>/**"],
      "program": "${workspaceFolder}/ts-debug/index.ts",
      "preLaunchTask": "tsc: build - ts-debug/tsconfig.json",
      "outFiles": ["${workspaceFolder}/ts-debug/**/*.js"],
      "cwd": "${workspaceFolder}/ts-debug"
    },
you need to have tsc compiler installed: `npm i -g typescript`
  1. Debugging Express Application

    debugging this process will require starting of the application and attaching the debugger to a processId

    {
      "name": "Express",
      "processId": "${command:PickProcess}",
      "request": "attach",
      "skipFiles": ["<node_internals>/**"],
      "type": "node"
    },
  1. Debugging Express-Nodemon Application
    {
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen",
      "name": "Nodemon-Express",
      "program": "${workspaceFolder}/express-debug/app.js",
      "request": "launch",
      "restart": true,
      "runtimeExecutable": "nodemon",
      "skipFiles": ["<node_internals>/**"],
      "type": "node"
    },
  1. Debugging NESTJS Application using npm/yarn
    {
      "command": "cd nest-debug && yarn run start:dev",
      "name": "NEST-Debug",
      "request": "launch",
      "type": "node-terminal"
    },
  1. Debugging NESTJS Application using launch
    {
      "type": "pwa-node",
      "request": "launch",
      "name": "Debug-NEST",
      "skipFiles": ["<node_internals>/**", "node_modules/**"],
      "program": "${workspaceFolder}/nest-debug/src/main.ts",
      "runtimeArgs": ["--no-lazy", "-r", "ts-node/register", "-r", "tsconfig-paths/register"],
      "console": "integratedTerminal",
      "sourceMaps": true,
      "cwd": "${workspaceFolder}/nest-debug",
      "internalConsoleOptions": "openOnSessionStart"
    },

vs-code-debugging's People

Contributors

debiprasadmishra50 avatar

Watchers

Abhijeet Sonaje avatar Tapas Thakkar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.