使用 PM2 和 Vscode 进行调试

ABD*_*MAL 9 debugging node.js pm2 visual-studio-code

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

Arc*_*hit 9

vs code 有一个名为 \xe2\x80\x9cAttach\xe2\x80\x9d 的调试选项,它允许您附加到正在运行的 Node.js 程序,\n示例配置如下

\n\n
{\n      "type": "node",\n      "request": "attach",\n      "name": "Attach",\n      "port": 9229\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

现在您需要启动 Node.js 程序,如下所示

\n\n
$ pm2 start "My App" --node-args="--inspect-brk" --watch\n
Run Code Online (Sandbox Code Playgroud)\n\n

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

\n