VS Code node远程调试:断点被忽略

时间:2017-02-28 22:27:13

标签: node.js visual-studio-code remote-debugging

我尝试在node.js(7.1.0)项目上使用VS Code设置远程调试。

我用pm2启动我的开发应用程序:

{
  "apps": [{
    "name": "my-app-dev",
    "script": "app.js",
    "watch": true,
    "node_args": ["--inspect=9229", "--nolazy"],
    "ignore_watch": ["assets/images/", ".tmp/", ".git/"],
    "watch_options": {
      "usePolling": true
    }
  }]
}

这是.vscode / launch.json文件:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node2",
            "request": "attach",
            "name": "attach",
            "port": 9229,
            "address": "my.app.local",
            "restart": true,
            "diagnosticLogging": true,
            "sourceMaps": false
        }
    ]
}

当我启动调试器时,我成功连接了Debugger attached.

问题是我的断点被忽略了:Unverified breakpoint

1 个答案:

答案 0 :(得分:2)

最后通过添加

找到了解决方案
"localRoot": "${workspaceRoot}/api",
"remoteRoot": "/srv/www/my-app/api"

到我的launch.json。

如果有人能解释为什么需要它:o