我有一个(Botpress Framework v.10.51.1)机器人,并且我安装了一个botpress模块​​并链接到该机器人,我想使用vscode调试器调试botpress模块​​中的代码,

我将以下代码添加到vs代码launch.json中,并使用命令npm start --debug启动了我的机器人

{
    "type": "node",
    "request": "launch",
    "name": "Launch Program",
    "cwd": "${workspaceRoot}",
    "port": 5859,
    "program": "${workspaceRoot}/node_modules/botpress/bin/botpress",
    "runtimeExecutable": "node",
    "runtimeArgs": [
        "--debug"
    ],
    "args": [ "start" ],
    "stopOnEntry": false
}


它仍然没有在vscode中启动调试器,我还缺少什么?我该怎么做呢?

最佳答案

很难说为什么它在Botpress 10上不起作用...

但是,如果克隆最新版本的Botpress回购(12.0.1),则会找到以下launch.json文件:

{
"version": "0.2.0",
"configurations": [
    {
     "type": "node",
     "runtimeVersion": "10.11.0",
     "request": "launch",
     "name": "Debug App",
     "program": "${workspaceFolder}/out/bp/index.js",
     "cwd": "${workspaceFolder}",
     "args": ["start"],
     "protocol": "auto",
     "env": {
       "BP_MODULES_PATH": "${workspaceFolder}/modules:${workspaceFolder}/internal-modules",
     "NODE_PATH": "${workspaceFolder}/out/bp",
     "DEBUG": "bp:*"
    },
    "smartStep": true,
    "outFiles": [
      "${workspaceFolder}/out",
      "${workspaceFolder}/modules/*/dist",
      "${workspaceFolder}/private-modules/*/dist",
      "!${workspaceFolder}/**/node_modules"
    ],
    "console": "integratedTerminal",
    "sourceMaps": true,
    "autoAttachChildProcesses": true
    }
  ]
}


这对于调试模块的后端部分非常有用。它仅要求您使用“ F5”键或转到“调试>开始调试”开始使用vscode进行调试。

我希望这个信息帮助。

关于node.js - 如何用vs代码调试安装在bot(botpress)中的botpress模块​​?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54074923/

10-10 14:37