首页 > 解决方案 > 使用 PM2 和 Vscode 进行调试

问题描述

Visual Studio 代码内置了一些很棒的调试功能,可以很容易地使用 node.js 调试应用程序。但是,我的应用程序配置为使用 PM2 版本 3.4.1。节点版本 6.17.1 如何设置 Visual Studio Code 以使用 PM2 进行调试?

标签: node.jsdebuggingvisual-studio-codevscode-settingspm2

解决方案


Vs code has a debugging option called “Attach” which allows you to attach to a running Node.js program, A sample configuration would be

{
      "type": "node",
      "request": "attach",
      "name": "Attach",
      "port": 9229
}

Now you need to start your Node.js program like below

$ pm2 start "My App" --node-args="--inspect-brk" --watch

vs code docs : https://code.visualstudio.com/docs/editor/debugging#_launch-versus-attach-configurations


推荐阅读