Node.js 使用VS代码调试React/node/express应用程序

Node.js 使用VS代码调试React/node/express应用程序,node.js,debugging,express,webpack,visual-studio-code,Node.js,Debugging,Express,Webpack,Visual Studio Code,我正在尝试调试我的express应用程序,我已经根据vs代码版本1.13帮助文档配置了IDE。但是,当我运行应用程序时,进程从未在断点处停止 我们正在开发一个react-redux/node/express应用程序,它使用webpack/babel 通常的启动脚本在3000/84431中启动我们的应用程序。 请查找我的启动配置文件launch.json: { // Use IntelliSense to learn about possible Node.js debug attribu

我正在尝试调试我的express应用程序,我已经根据vs代码版本1.13帮助文档配置了IDE。但是,当我运行应用程序时,进程从未在断点处停止

我们正在开发一个react-redux/node/express应用程序,它使用webpack/babel

通常的启动脚本在3000/84431中启动我们的应用程序。 请查找我的启动配置文件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

我建议在您的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”添加到您的网页配置中,以便在源代码中触发断点。

您使用的是node v6.3.0+?谢谢@Gerardo Roza,让我试试这个