【问题标题】:How can I debug a Node.js application running with PM2 in VSCode?如何在 VSCode 中调试使用 PM2 运行的 Node.js 应用程序?
【发布时间】:2017-04-19 02:45:19
【问题描述】:

Visual Studio 代码内置了一些很棒的调试功能,可以轻松使用 node.js 调试应用程序。但是,我的应用程序配置为使用 PM2。如何设置 Visual Studio Code 以使用 PM2 进行调试?

【问题讨论】:

  • 如何在调试模式下启动一个vscode可以使用的node.js应用程序?节点 --debug app.js?

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


【解决方案1】:

您可以在 VSCode 中的 launch.json 文件中添加启动配置,该配置附加到您想要的进程,如下所示:

{

  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "attach",
      "name": "Attach to Process",
      "processId": "${command:PickProcess}"
    },
    {...}
  ]
}

ctrl+shift+D 在 Visual Studio Code 中显示调试部分,选择“附加到进程”,然后按“播放 >”。 VSCode 将自动向您显示本地计算机上可用的选项。除了正在运行的节点进程的进程 ID,VSCode 还显示了节点应用程序的完整路径,因此很容易选择要附加的正确进程。

【讨论】:

    猜你喜欢
    • 2020-08-10
    • 2015-07-06
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    • 2011-09-22
    • 2021-02-04
    • 2016-12-10
    • 1970-01-01
    相关资源
    最近更新 更多