使用vscode 通过端口remote attach进行调试 pomelo.
0. 网上好多调试pomelo的都是webstorm.或者vscode调试node的教程.但没找到vscode调试pomelo的.
1. node 环境
node 使用版本
v8.11.1
node 查看 调试参数 ==> node -h 找出调试相关 参数,如果你在阅读本文后调试不成功,看看是不是调试的参数不对
node inspect script.js [arguments]
--inspect[=[host:]port] activate inspector on host:port
--inspect-brk[=[host:]port]
activate inspector on host:port
--inspect-port=[host:]port
set host:port for inspector
2. pomelo 配置
版本: 2.2.5
以connector为例,编辑servers.json,将如下配置添加到 connector的配置末尾
"args": " --inspect=127.0.0.1:16772"
```
"connector": [
{"id": "conn1", "host": "127.0.0.1","port": 3150, "natHost":"192.168.0.108","natPort": 3010, "clientPort": 3010, "frontend": true,"reloadRemotes":true,"args": " --inspect=127.0.0.1:16772 "}
],
```
3. vscode 使用 remote attach 配置, 编辑launch.json(菜单栏==> 调试 ==> 添加配置)
```
{
"type": "node",
"name": "Attach to Remote",
"port": 16772,
"request": "attach",
},
```
4. 点击开始调试命令即可