Home  >  Article  >  Development Tools  >  A brief analysis of the method of debugging Node.js in VSCode

A brief analysis of the method of debugging Node.js in VSCode

青灯夜游
青灯夜游forward
2021-09-14 19:09:322316browse

How to debug Node in VSCode? The following article will introduce to you the method of debugging Node.js in VSCode. I hope it will be helpful to you!

A brief analysis of the method of debugging Node.js in VSCode

The simplest way to debug: Run Current File

Because VSCode has a built-in Node debugger, debugging Node is extremely simple, follow these steps. [Recommended learning: "vscode tutorial"]

Run Current File

  • Find the Run And Debug button in the ToolBar And click, or directly 4795a28b7114f13f6a7515205117f293 to open debugging

  • Select Run Current File

    # in the debug panel
  • ##Click the small green debugging button to start debugging

Run Current File For debugging NodeJS, it is just a click. How to debug Typescript and more complex large projects?

Debug Project: JavaScript Debug Terminal

If there is a

ts file that needs to be debugged, how should it be handled?

Javascript Debug Terminal

  • #d538879885a84ef913fb4c521308657f

    Open Terminal

  • at
  • Terminal

    Click the small button on the right side of the panel, and continue to click Javascript Debug Terminal to open the JS debugable terminal

  • Enter the command to execute the ts file:
  • npx ts-node index.ts

  • If starting the project is particularly complicated, how to deal with it?

The following is an example (although it is not particularly complicated), abstracting the startup command as

npm start

.

{
  "scripts": {
    "start": "NODE_ENV=production node index.js"
  }
}
The second step, enter the command in the debuggable terminal

npm start

The third step, start debugging

More programming related knowledge, Please visit:

Introduction to Programming

! !

The above is the detailed content of A brief analysis of the method of debugging Node.js in VSCode. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:juejin.cn. If there is any infringement, please contact admin@php.cn delete