Right now we need to modify the bin/botpress file line 1 to include --inspect or --debug. There should be an easier way for bot makers, like: botpress start --debug or npm run debug
@slvnperron can you post your bin/botpress code? I'm struggling there to debug botpress.
@ricardovsilva Are you trying to debug the botpress core or a botpress bot?
Here's how to debug a node process: https://nodejs.org/api/debugger.html
You modify your local botpress (i.e. the one in your bot's node_modules/botpress/bin)
#!/usr/bin/env node --inspect
require('../lib/node.bundle.js').CLI()
@slvnperron botpress bot. Just for record, for other people struggling with that also. I achieved a great node debug using NIM chrome extension and starting process on vs code using F5.
@ricardovsilva can you please tell me the steps exactly ? because I tried what you say but don't really understand the extension job with vs
@bishoymelek, when you run code with debug or inspect, in fact, node open two ports to any debugger attach to it.
When you press F5 on vs code, it run's the project with --inspect flag, ports for debug are open, then vs attach to one of that ports. But, for some reason, vscode is a little buggy to debug nodejs codes, specially with botpress.
NIM chrome extension is just another debug tool that connect to some debug port of node.
Then steps are:
There's a request from Raghav Garg on running debug from VS Code:
Hey, I am trying to run the bot in vs code debugger. But no success. This is the below configuration I am using,
{ "type": "node", "request": "launch", "timeout": 15000, "name": "Launch via NPM", "runtimeExecutable": "npm", "env": { "DATABASE": "postgres", }, "runtimeArgs": [ "start", "--inspect=3000", ], "port": 3000, "restart": true, "console": "integratedTerminal", "internalConsoleOptions": "neverOpen", }keep on getting the error
Cannot connect to runtime process, timeout after 15000 ms - (reason: Cannot connect to the target: <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Error</title></head><body><pre>Cannot GET /json/list</pre></body></html>).
Most helpful comment
You modify your local botpress (i.e. the one in your bot's node_modules/botpress/bin)