我正在尝试调试我的快速应用程序我已根据vs代码(版本1.13 )帮助文档配置了我的IDE。但是当我运行应用程序时,进程永远不会在断点处停止。
我们正在开发一个使用webpack / babel的react(redux)/ node / express应用程序。
通常的启动脚本在3000/8443(安全)中启动我们的应用程序。 请找到我的启动配置文件(launch.json):
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"runtimeExecutable": "npm",
"runtimeArgs": [
"start",
"debug"
],
"env": {
"NODE_ENV": "development"
},
"console": "integratedTerminal",
"sourceMaps": true,
"outFiles": ["${workspaceRoot}/dist/*/.js"],
"port": 5858
}
]
}
启动时,我们收到以下错误:
Cannot connect to runtime process, timeout after 10000 ms - (reason:
Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:5858).
我在这里错过了什么吗? 我正在使用osx(10+)进行开发
谢谢, Santhosh
答案 0 :(得分:1)
我建议您在dev
中设置一个package.json
脚本,如下所示(我在其中包含了开始脚本,以便您在“开发”脚本中找出要写的内容:
"scripts": {
"start": "cd dist && node main",
"dev": "cd dist && node --inspect=5858 main"
},
然后配置你的launch.json
以使用该脚本(启动npm监听调试器):
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run",
"dev"
],
"port": 5858,
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/dist/"
],
"cwd": "${workspaceFolder}"
},
]
}
另外,不要忘记将devtool: 'sourcemap'
添加到您的webpack配置中,以便在源代码中触发断点。