步骤
详细
1. 在server的配置中添加 args 参数,此参数为node开启此服务器时命令参数
"gate": [
{"id": "gate-server-1", "host": "127.0.0.1", "clientPort": 3014, "frontend": true, "args": " --inspect=5858"}
]
使用--inspect 还是 --debug 似乎与node版本有关,暂不知两者关系,留待后续研究。。。
2. 在vscode中添加调试配置,添加一个远程调试,port为--inspect对应的端口
{
"type": "node",
"request": "attach",
"name": "Debug remote",
"address": "127.0.0.1",
"port": 5858,
"localRoot": "${workspaceRoot}/game-server"
}
上面时远程调试服务的,下面一个调试app.js入口文件
{
"type": "node",
"request": "launch",
"name": "启动程序 (development)",
"program": "${workspaceRoot}/app.js",
"args": ["env=development","type=all"]
}
参考自:https://www.cnblogs.com/pampam/p/4059078.html