Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

visual studio code node.js debugger fails to attach on standard launch

I tried to use the simple node.js example visualstudio code provides, but unfortunately when node is being started from visual studio code (on OS X) the node gets started with some arbitrary debug-brk, but debugger attachment fails.

When I run the node app manually with --debug-brk = 5858 and then use the attach I can debug my app. Anyone faced the same problem?

P.S I got mono installed from the mono project page .pkg

Here is my launch.js:

{
"version": "0.1.0",
// List of configurations. Add new configurations or edit existing ones.  
// ONLY "node" and "mono" are supported, change "type" to switch.
"configurations": [
    {
        // Name of configuration; appears in the launch configuration drop down menu.
        "name": "Launch app",
        // Type of configuration. Possible values: "node", "mono".
        "type": "node",
        // Workspace relative or absolute path to the program.
        "program": "./bin/www",
        // Automatically stop program after launch.
        "stopOnEntry": true,
        // Command line arguments passed to the program.
        "args": [],
        // Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
        "cwd": ".",
        // Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
        "runtimeExecutable": null,
        // Environment variables passed to the program.
        "env": { }
    }, 
    {
        "name": "Attach",
        "type": "node",
        // TCP/IP address. Default is "localhost".
        "address": "localhost",
        // Port to attach to.
        "port": 5858
    }
]

}

like image 732
Jan Paul Avatar asked Apr 30 '15 18:04

Jan Paul


People also ask

Why is my debugger not working in VS Code?

The most common problem is that you did not set up launch.json or there is a syntax error in that file. Alternatively, you might need to open a folder, since no-folder debugging does not support launch configurations.

How do you attach a debugger to a Node?

Debug with V8 Debugging ProtocolCreate an Attach to Node. js/Chrome run/debug configuration as described above and specify the host and the port passed to --debug . The default port is 9229. Make sure the application to debug was launched with the following parameters: --debug=<debugger port> .

How do I enable auto attach in or code?

Auto Attach# js processes that have been launched from VS Code's Integrated Terminal. To enable the feature, either use the Toggle Auto Attach command from the Command Palette (Ctrl+Shift+P) or, if it's already activated, use the Auto Attach Status bar item.

Why Node is not working in VS Code?

You must click the Kill Terminal button (highlighted) and then restart VS Code and node will start working again. Best on making a change of system environment variable Path is restarting Windows to make sure that really all processes make use of the modified Path variable.


1 Answers

Just ran into the same issue... Code couldn't find Node.

Change this line to point to your executable, for example:

"runtimeExecutable": "C:/Program Files/nodejs/node.exe",

Enjoy!

like image 106
Believer Avatar answered Sep 18 '22 14:09

Believer