Introduction to 1-1 inspector
Git bash common commands
-
mkdir test
New folder -
cd test
Enter folder -
cd ../
Enter parent folder -
ls
Lists the files and folders under the current folder -
Code the name of the folder in the current directory
The corresponding project can be opened through a global variable code provided by vscode
Vs Code for breakpoint debugging
Press F5 to start a websocket service for debugging, and the following will be printed on the debugging console:
D:\Program Files\nodejs\node.exe --inspect-brk=24775 app.js
Debugger listening on ws://127.0.0.1:24775/6cc7bcf1-c9fc-4f58-a819-2dd38e9fb9bf
For help, see: https://nodejs.org/en/docs/inspector
The corresponding HTTP service is:
http://127.0.0.1:24775
Add JSON at the end to view the corresponding meta informationhttp://127.0.0.1:24775/json
1-2 activation debugging
node --inspect app.js
Add — inspect at runtime to activate debugging
Using express to build a service startup debugging
-
npm init
Initialize a package manager and specify the entry file( app.js ) -
npm install express --save
Install express module - In the entry file app.js Write service code in
const express = require('express')
const app = express()
app.get('/', (req, res) => {
res.send('hello world !')
})
app.listen('3000', () => {
console.log ('Program runs on port 3000 ')
})
-
node --inspect app.js
Run the command to start debugging
Note: you need to set vscode, search for attach in the settings, and change the value of debug > node: Auto attach to on
1-3 ~ 4 debug client – chrome devtools
Start debugging client
-
Method 1:
- Input in the Chrome browser chrome://inspect
- Select devices
- Click Configure… To configure done
- Then click inspect under target
-
Method 2:
The devtoolsfrontendurl in meta information can also be opened directly in the browser
View meta information -
Law 3:
Open the browser developer tool and click the green icon in the upper left corner to enter -
Law 4:
Using the debugging function of vscode
1-5 debug client vscode
- Start method: shortcut key F5
- to configure: launch.json
- Print parameter list in node:
console.log(process.argv)
Introduction of 1-6 command line parameters
- Official documents
This work is original and adopts the “signature – noncommercial use – no deduction 4.0 international” license agreement