vscode可以通过配置debug模式来实现断点调试。
Debugger for Chrome
插件{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome",
"url": "http://127.0.0.1:7001/payment/domain/reports#/task/list/136978-1001-1001?_k=nbm3t3",
"webRoot": "${workspaceFolder}"
}
url即为项目入口路径
{
"type": "node",
"request": "launch",
"name": "node debug",
"program": "${workspaceFolder}/index.js",
"autoAttachChildProcesses":true,
"stopOnEntry": false
}
这里的index.js,即为入口js。
{
"type": "node",
"request": "launch",
"name": "node debug",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "npm",
"timeout": 60000,
"runtimeArgs": [
"run",
"debug"
],
"port": 9229,
"autoAttachChildProcesses":true,
"stopOnEntry": false
}
runtimeArgs的第一个参数通常固定为
run-script
,但这意味着package.json中配置的执行命令必须是以node执行的。如果命令是非node执行,例如webpack等,则会出现断点未绑定的情况,可尝试将第一个参数修改为run
。第二个参数即为debug模式启动项目的命令名。
详细属性可参照:https://code.visualstudio.com/docs/nodejs/nodejs-debugging