I am running node app using pm2 with --inspect flag. I am able to debug my app on the following url:
chrome-devtools://devtools/remote/serve_file/#62cd277117e6f8ec53e31b1be58290a6f7ab42ef/inspector.html?experiments=true&v8only=true&ws=local.abc.com:9003/node
How can I debug this application using VS Code built in debugger?
If you have launched your node app from the command line create this "attach" launch config:
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 9222,
"protocol": "inspector"
}
or let VS Code launch your app and attach to it in one go:
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceRoot}/your_app.js",
"protocol": "inspector"
}
Related
My current method is to run npm run dev in a terminal. which uses cross-env NODE_OPTIONS='--inspect' next dev (i tried it without cross-env and it wont run).
then i attach a node debugger to the running process with the following script in VS code
{
"name": "Attach",
"port": 9229,
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node",
}
and then finally i launch chrome with another debugger script
{
"name": "Launch Chrome",
"request": "launch",
"type": "pwa-chrome",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
}
I have tried the solution outlined here and the process don't run.
I have also tried this configuration (both node and node-pwa variants) they run but dont seem to actually do any debugging, nor are there any messages in the console (or debug console).
{
"type": "node",
"request": "launch",
"name": "Launch via NPM: node",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script",
"dev"
],
"port": 9229,
"skipFiles": [
"<node_internals>/**"
]
}
idealy, i would like to be able to press a single button and have it all launch up for me, currently it is a 3 step process, but i would happily take converting the attach task to a launch task.
I am trying to debug a dockerized Node.js application written in TypeScript.
I followed a tutorial that says that I should configure Nodemon and expose a port on the app container so the debugger can listen to.
When I run the debugger from VS Code I got a disabled Breakpoint with this message “Breakpoint ignored because generated code not found”.
This is my launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Server",
"type": "node",
"port": 9229,
"restart": true,
"protocol": "auto",
"request": "attach",
"remoteRoot": "/server/dist",
"localRoot": "${workspaceFolder}/packages/back/dist",
"skipFiles": ["<node_internals>/**/*.js"],
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
}
]
}
I am trying to make the debugger work on VS code using node but without any success as breakpoints are not hitting.
I tried to set the launch.json in many different configs but with no luck.
"type": "node",
"request": "attach",
"name": "Attach",
"port": 9229,
"skipFiles": [
"<node_internals>/**"
]
},
{
"type": "node",
"request": "launch",
"name": "Server",
"runtimeExecutable": "nodemon",
"program": "${workspaceRoot}/src/index.ts",
"console": "integratedTerminal"
},
I am using a graphql running on node apollo and typescript on my machine with Visual Studio Code
In all the tutorials using http triggers, the .vscode launch file has this:
{
"name": "Attach to Javascript Functions",
"type": "node",
"request": "attach",
"port": 9229,
"preLaunchTask": "func: host start"
}
So now I've added a second function in the same function app. It uses a service bug trigger. I'd like to test it locally before deploying to azure. So now how do I extend the launch configurations? I can copy the block and change the name but how will the debugger know which func to kick off?
Thanks!
No modification required actually. The inspector(debugger) is not attached to any specific function, instead, it is enabled for the function node worker, which loads all functions we create.
When we debug we could see
Starting language worker process:node --inspect=9229
"C:\Users\UserName\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\node\dist/src/nodejsWorker.js" --host ...
node process with Id=2276 started
Generating 2 job function(s)
Debugger listening on ws://127.0.0.1:9229/0c8f2c9a-80cd-4ab6-914e-1c65d29f43c6
Latest VSCode version 1.61.0 breakpoint unbound.
my config
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"preLaunchTask": "npm: start",
"sourceMaps": true,
"smartStep": true,
"port": 58167,
"protocol": "inspector",
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
}
}
Today my VSCode got upgraded to 1.2.0, since then VSC debugger is failing. So based on the documentation we added a "protocol": "inspector". But now we are getting another error saying Ensure Node was launched with --inspect. Cannot connect to runtime process, timeout after 10000 ms
My current launch.json looks like
launch.json
{
// 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": "attach",
"name": "Attach",
"protocol": "inspector",
"port": 9229
},
{
"type": "node",
"request": "launch",
"protocol": "inspector",
"name": "Launch Program",
"program": "${workspaceFolder}/test"
}
]
}
VSCode Version: Version 1.20.0 (1.20.0)
Node Version: 8.1.2
Any pointers for fixing this issue would be great help
Thanks,
San