Coder Social home page Coder Social logo

node-debugger-example's Introduction

debug mode

What is Launch / Attach

Launch

VSCode will start a new process to debug Node.js

Attach

  1. Run Node.js manually, use websocket to listen to debug info
  2. Start a process attach to websocket port

Chrome debug

Launch

  1. node --inspect-brk index.js
  2. Open Chrome, go to chrome://inspect

  1. Start debugging!

Attach

  1. node --inspect-brk server.js
  2. Open Chrome, go to chrome://inspect
  3. Let go of first breakpoint
  4. Add breakpoint
  5. Visit localhost:3000, start debugging

VSCode debug

Add configuration file

Create .vscode/launch.json

{
  "version": "0.2.0",
  "configurations": [
      {
          "type": "node",
          "request": "launch",
          "name": "Launch",
          "program": "${workspaceRoot}/index.js"
      },   
      {
          "type": "node",
          "request": "attach",
          "name": "Attach",
          "port": 9229
      },
      {
        "name": "Attach to nodemon",
        "type": "node",
        "request": "attach",
        "restart": true,
        "port": 9229
      }
  ]
}

Launch

  1. Go to Run Extension
  2. Launch Node.js
  3. Start debugging

Attach

  1. node --inspect-brk server.js
  2. Go to Run Extension, start attach process
  3. Let go of first breakpoint
  4. Add breakpoint
  5. Visit localhost:3000, start debugging

Nodemon

  1. nodemon --inspect-brk server.js
  2. Almost the same as above, apart from starting the Attach to nodemon

Happy Debugging!

node-debugger-example's People

Contributors

ymyqwe avatar

Watchers

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