我试图通过Visual Code调试器运行我的MEAN应用程序,但我无法启动它。它显示Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:58...
错误。我正在运行Node 8.1.0和npm 5.0.3。这是我的启动配置文件
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"runtimeExecutable": "npm",
"windows": {
"runtimeExecutable": "npm.cmd"
},
"runtimeArgs": [
"run",
"startdev"
],
"port": 5858,
"protocol": "inspector"
}
]
}
每当我执行我的程序时,我都会使用npm run startdev
运行它,startdev
是我package.json
中的脚本。如何启动调试器?
编辑:
我正在使用npm run startdev
运行应用,其中startdev
是
"startdev": "concurrently \"ng build --watch\" \"cross-env NODE_ENV=development nodemon ./bin/start.js\""
我也尝试了附加配置,但无济于事
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"processId": "${command:PickProcess}",
"port": 5858
}
答案 0 :(得分:1)
您应该使用attach配置将调试器附加到节点进程。
您还需要使用debug标志启动该过程 像
这样的东西node --debug <filename>
正如OP在评论中所指出的,调试标志已被弃用。所以使用inspect flag。
node --inspect <filename>
附加配置看起来像
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858,
"address": "localhost",
"restart": false,
"sourceMaps": false,
"outFiles": [],
"localRoot": "${workspaceRoot}",
"remoteRoot": null
}
在文档here
中有关于此的更多信息