You can use console.log and see output in the nodebb logs, vscode debugger also works and let's you step through code and see the data. Below is my launch.json file for vscode debugging.
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "NodeBB",
"skipFiles": [
"${workspaceFolder}\\node_modules\\**\\*.js",
"${workspaceFolder}\\src\\promisify.js",
"<node_internals>/**"
],
"program": "${workspaceFolder}\\app.js",
"runtimeArgs": [
"--trace-warnings",
"--stack-trace-limit=200"
]
}
]
}
If you are debugging a plugin/theme in node_modules folder remove the node_modules part from skipFiles