grunt.log.writeln is not displayed in vs code debug console - node.js

I am trying to debug gruntfile.js in VS Code. My launch.json looks like this:
{
"name: Grunt",
"type": "node",
"request": "launch",
"program": "/usr/local/bin/grunt",
"args": ["build_script"],
"cwd": "${workspaceRoot}",
"stopOnEntry": false,
"console": "internalConsole"
}
It works and I can debug it using breakpoints, etc., but the issue is that all outputs which are done with grunt.log.writeln(..), grunt.fail.warn(..) are not displayed in debug console.
How to make grunt to use the debug console for grunt.log?
Thanks

Related

How do you debug a botpress-module installed in bot (botpress) in vs-code?

I have a (Botpress Framework v.10.51.1) bot and I have a botpress-module installed and linked to the bot, I wanted to debug the code in the botpress-module using vscode debugger,
I added the following to my vs-code launch.json and started my bot with the command 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
}
It's still not launching the debugger in vscode , What am i missing ? How do I do this?
It's hard to tell why it doesn't work on Botpress 10...
However, if you clone the latest version of the Botpress repo (12.0.1), you'll find the following launch.json file:
{
"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
}
]
}
Which works great for debugging the backend part of modules. It only requires you to start debugging with vscode using the "F5" key or by going to "Debug > Start Debugging".
I hope this information helps.
#Mahesh VSCode allows you to easily debug Botpress. I have created a tutorial that can help understand what are the different ways you can debug a problem in Botpress.
We will use VSCode debugging and Botpress logging capability to find and resolve bugs in our bot
Let us try to debug this, by adding 3 additional statements debugger, console.log & bp.logger.info in our ValidateEmailSignature custom action.
Please checkout below tutorials for more information
https://youtu.be/89dFPVbXxCw
https://aabingunz.com/debugging-in-botpress/

Error coming while debugging my typescript file:-> Debugger attached. Waiting for the debugger to disconnect

I have gone through plethora of articles online ,I have tried every possible way given online for this but nothing has worked for me till now.
I have reinstalled node,vs code,npm all again but nothing is working.
I am using ->
VSCode Version: 1.27.2
OS Version: Windows 10 Pro 64bit OS,x64-based processor
Node version: v8.11.3
My launch.json is as follows:-
{
// 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": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/dist/LeonardoGrader.js",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": ["${workspaceRoot}/dist/**/*.js"]
}
]
}
Any help will be appreciated.Thanks in advance.
That output means that your program ran to completion without ever stopping in the debugger. Either set some breakpoints or change the stopOnEntry option to true to stop the program on the first line of code.

How can I fix the Python Debugger error(crash) on Visual Studio Code?

Whenever I try to start debugging Python, this bar on the picture does not appear and I only get the output of My code. How can I fix it?This happens when I start debugging This Bar is missing
I got the same problem. It suddenly started to happen.
I could solve it copy pasting a config I have in another computer.
Try adding this configuration to your 'launch.json' file in vs code and use it for debugging:
{
"name": "Python",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"cwd": "${workspaceFolder}",
"env": {},
"envFile": "${workspaceFolder}/.env",
"debugOptions": [
"RedirectOutput"
]
}

Winston Logger - NodeJs Debug console logs not showing in VSCode

I'm using VSCode debugger and winston logger for NodeJS, but can't see output from application unless I specify external terminal like this:
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/server.js",
"console": "externalTerminal"
}
]
Is there way to see that output in output window, like when i start code using CodeRunner plugin?
When using a logger that outputs to
process.stdout.write
you can use
"outputCapture": "std" in the launch config to also capture that.

How to call API from backend under vscode debugger?

How can I call an API which is being served by the vscode debugger?
I would usually call http://localhost:3000/api/plugins, but clearly my project isn't served on that port. My launch.json look like this:
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/server/app.js",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": null,
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"console": "internalConsole",
"sourceMaps": false,
"outDir": null
},
and the output from the debug console:
node --debug-brk=12834 --nolazy server\app.js
Debugger listening on [::]:12834
MongoDB Connection Succesful
I have tried the API with Postman on both localhost:12834 and localhost:5858 (which is the port in the attach configuration - neither work...
In visual studio code, you can debug node.js code with its inbuilt debugger. For that you don't need to call api with the debugging port(In your case 12834). You just need to call with port defined in your express configuration (generally 3000).
You have to start debugging from visual studio code with F5. So, your debugging start for the project and you need to put break point on method, you want to debug. So, when your api call from frontend, you will get point on vscode.

Resources