VSCode for react application debugging (node version 8.1.2) - node.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

Related

(Unbound Breakpoints) How to debug nestjs project in vscode for nx project

I am trying to debug my nestjs application created by NX project in vs code. I added Launch.json file which is look like below. I have two projects in it one is angular and second one is nestjs I want to debug my nestjs project.
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach by Process ID",
"processId": "${command:PickProcess}",
"skipFiles": ["<node_internals>/**"]
},
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/serve",
"outFiles": ["${workspaceFolder}/**/*.js"]
}
]
}
Whenever I try to add breakpoints they are become grey in color and shows that they are unbound breakpoints even after pointer goes to the breakpoint still not pause at it. Please help me with any solution.

Debug Node.js with TypeScript and Docker in VS Code: “Breakpoint ignored because generated code not found”

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"],
}
]
}

debugging apollo, docker and typescript on VS code

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

Running nest.js from VS Code

So, I'm playing around with this new framework http://nestjs.com/ who seems pretty awesome since it allows the usage of Typescript on Node, very likely to angular.
Using the starter https://github.com/kamilmysliwiec/nest-typescript-starter, I can run it with npm run start without any problem, but since there is a .vscode on the project, I assumed I could use VS Code to run and gain some debug abilities.
The problem is that when I run directly from VS Code, without changing anything in the code, I get the following problem:
Error: Cannot find module 'nest.js'
I tried to run from VS Code with and without it running from NPM, no success.
Thanks in advance.
I updated nest-typescript-starter today. The previous version had an old dist directory, with outdated imported packages. If you want to compile your application, use npm run start:prod script.
To debug with nestjs app.
In 2020, after I follow first-step.
In VS code change default setting from:
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/start",
"preLaunchTask": "tsc: build - tsconfig.json",
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
]
}
]
to this:
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/src/main.ts",
"preLaunchTask": "tsc: build - tsconfig.json",
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
}
]
And press F5 to debug.
It works perfectly with me.
For those looking for a launch.json. There is one described at https://github.com/nestjs/nest/issues/776
{
// 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": "Launch Program",
"program": "${workspaceFolder}\\src\\main.ts",
"preLaunchTask": "tsc: build - tsconfig.json",
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
]
}
]
}

VSCode Debug Node app using Inspector protocol

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"
}

Resources