Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example of vscode debugging js

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you an example of vscode debugging js, I hope you will learn a lot after reading this article, let's discuss it together!

How does vscode debug js?

There are two relatively simple ways to debug JavaScript code.

1. Debug using browsers such as Chrome

two。 Configure the JavaScript runtime environment in vscode

Configuration steps:

1. Download and install Node.js (Node.js is a running environment for JavaScript)

This can be found on Node.js 's official website or Chinese website.

two。 Configure vscode

Click the "debug" button in vscode to open the launch.json file (or enter launch.json using Ctrl+Shift+P)

Add to it

"version": "0.2.0", "configurations": [{"name": "Launch", "type": "node", "request": "launch", "program": "${workspaceRoot} / 1.js", "stopOnEntry": false, "args": [] "cwd": "${workspaceRoot}", "runtimeExecutable": null, "runtimeArgs": ["- nolazy"], "env": {"NODE_ENV": "development"}, "externalConsole": false, "preLaunchTask": "", "sourceMaps": false, "outDir": null} {"name": "Attach", "type": "node", "request": "attach", "port": 5858}]

Note: ${workspaceRoot} is the absolute path for the current program to work.

3. Debug

Create a new js file, change the 1.js in program in launch.json to the name of the file you want to debug, and put the changed file under the absolute path

(function name (params) {console.log ("message");}) ()

Debug with F5 to get

Node-- debug-brk=37692-- nolazy Untitled-1.jsDebugger listening on [:]: 37692message has finished reading this article, I believe you have some understanding of the example of vscode debugging js, want to know more about it, welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report