我的调试配置如下launch.json
:
{
"type": "node",
"request": "attach",
"preLaunchTask": "npm: start",
"name": "Attach",
"port": 9090
}
这是定义在中的任务tasks.json
:
{
"type": "npm",
"script": "start",
"isBackground": true
}
npm start
做这个:node --inspect=9090 ./src/server.js
如果我删除preLaunchTask
调试配置,手动启动任务,然后启动调试会话,一切正常(调试会话附加节点进程)。
然而,随着preLaunchTask
,启动调试后约 10 秒,我收到此错误:“无法跟踪指定的任务”。
当任务设置为时,似乎可能需要问题匹配器isBackground
,所以我也尝试了这个任务配置但没有成功:
{
"type": "npm",
"script": "start",
"isBackground": true,
"problemMatcher": {
"background": {
"activeOnStart": true,
"beginsPattern": "^.*Using environment.*",
"endsPattern": "^.*listening.*"
}
}
}
的输出npm: start
5:13:12 PM web.1 | Using environment: production
5:13:12 PM web.1 | Already up to date
5:13:12 PM web.1 | Debugger listening on ws://127.0.0.1:9090/22d582b8-eade-4b27-95f4-e36ad1718283
5:13:12 PM web.1 | For help see https://nodejs.org/en/docs/inspector
我需要问题匹配器吗?如果是这样,为什么?当我自己开始任务时,它工作正常。我没有任何问题需要报告...