This guide will help you get started with debugging. There are multiple things you can debug and you need a different configuration for each one:
- Debug your client code - No configuration needed, just open devtools on your browser.
- Debug your server code -
yoshi start --debug
- Debug your tests -
yoshi test --debug
When debugging your server/tests you'll need to configure the debugger, depend on your prefered way to debug.
When started with the --debug
option, Yoshi will allow to attach NodeJS debugger to the relevant child process with the default host and port.
You can configure the default port by: --debug=XXXX
When started with the --debug-brk
option, Yoshi will allow to attach NodeJS debugger and the relevant child process won't start until debugger will be attached.
You can configure the default port by: --debug-brk=XXXX
.
Several commercial and open source tools can connect to Node's Inspector and there for can debug Yoshi tasks. Basic info on these follows:
- Option 1: Open
chrome://inspect
in a Chromium-based browser. Click the Configure button and ensure your target host and port are listed. - Option 2 - ✅ Recommended: Install the Chrome Extension NIM (Node Inspector Manager):https://chrome.google.com/webstore/detail/nim-node-inspector-manage/gnhhdgbaldcilmgcpfddgdbkhjohddkj
- In the Debug panel, click the settings icon to open
.vscode/launch.json
. Select "Node.js" for initial setup. - 📌 You must tell vscode the target debugging port, otherwise vscode will try to debug Yoshi's main process in random generated port, so add
"port" : 9229
(or the port you choose) - Example launch.json -
{
"name": "Run Tests",
"type": "node",
"request": "launch",
"args" : ["test", "--debug"],
"port": 9229,
"program": "${workspaceFolder}/node_modules/.bin/yoshi"
}