简体   繁体   中英

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?

PS 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
    }
]

}

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!

Might be the cluster thing. Try to turn off cluster in ./bin/www, and you will be able to debug it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM