Visual Studio Code node.js debug: "Connection failed" error

I am following the official guide exactly: https://code.visualstudio.com/Docs/nodejs
At the end of the guide:

"... and press F5 to start debugging

I am getting the following error:

Connection error with error

I am using Debian Jessie.

+3


source to share


1 answer


I am running VSCode v0.3.0 on GNU / Linux Ubuntu 12.04 LTS x64.


I can use the built-in VSCode debugger and use VSCode to attach to a node process running in debug mode.

You mentioned that you are using debian / jessie GNU / Linux and Express and Node are listed in your tags, so the following might be helpful.

Make sure you don't have any node processes running that will conflict with the connection by running an app like performance monitor (or an app or command line tool of your choice) and kill any node or nodejs that may not have been executed correctly.

Double check your Mono installation location and v3.12 or higher (v4.0.1 or higher when developing for vNext ASP.net 5).

You can install Mono using any method you like as long as its version is v3.12 or higher. I decided to download, compile and install Mono under / opt for my distribution from mono-project .

15:15:34 ツ gjsmith3rd@DV7:~ >which mono /opt/mono/mono-4.0.1/bin/mono

15:15:38 ツ gjsmith3rd@DV7:~ >mono --version Mono JIT compiler version 4.0.1 (tarball Wed Jun 3 09:11:07 CDT 2015) Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com TLS: __thread SIGSEGV: altstack Notifications: epoll Architecture: amd64 Disabled: none Misc: softdebug LLVM: supported, not enabled. GC: sgen

You will want to pay attention to your Mono installation location for configuring your environment . In my case, the location /opt/mono/mono-4.0.1/*

. You will need to change the location to reflect the real environment. Once you have determined the correct version and installation location, make sure the installation has correctly configured the environment variables in your .bashrc, .bash_profile, or appropriate shell environment for your distribution.

``,



export PATH=/opt/mono/mono-4.0.1/bin:$PATH
export MONO_LOG_LEVEL=debug
export MONO_LOG_MASK=asm
export LD_LIBRARY_PATH=/opt/mono/mono-4.0.1/lib:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=/opt/mono/mono-4.0.1/pkgconfig
export MONO_PATH=/opt/mono/mono-4.0.1/lib

      

``,



Again, the paths should reflect the locations in your environment. If you make any changes to your environment submit your shell or log out and log back in.

$source .bashrc

Start VSCode or close and restart VSCode .

In your VSCode debug config file (press the transfer symbol in the debug version Run config ) launch.json make sure your application is debugged node: "type": "node" .

``,



{
    "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 server.js",
            // Type of configuration. Possible values: "node", "mono".
            "type": "node",
            // Workspace relative or absolute path to the program.
            "program": "server.js",
            // 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": "10.0.0.57",
            // Port to attach to.
            "port": 5858
        }
    ]
}

      

``,



Save your changes.

If you want to connect to a running node process, start the node application from the command line in your application directory.

$node debug appname.js

Now you can use the node command line to continue the debugging process.

``,



17:37:51 ツ gjsmith3rd@DV7:(master)~/Workspaces/Development/devsandbox >node debug server.js
< Debugger listening on port 5858
debug> . ok
break in server.js:5
  3 
  4 //  OpenShift sample Node application
> 5 var express = require('express');
  6 var fs = require('fs');
  7 // var bootstrap = require("bootstrap");
debug> next
break in server.js:6
  4 //  OpenShift sample Node application
  5 var express = require('express');
> 6 var fs = require('fs');
  7 // var bootstrap = require("bootstrap");
  8 
debug> 

      

``,



or start VSCode and attach the debugger to the running node debug process. Make sure your VSCode Launch Configuration has an entry attach

that is properly configured and launched from VSCode by selecting the debugger dropdown menu. You want to customize the IP and port to your requirements.

``,



{
                "name": "Attach",
                "type": "node",
                // TCP/IP address. Default is "localhost".
                "address": "localhost",
                // Port to attach to.
                "port": 5858
            }

      

``,



Finally, you can start the debugger from VSCode without using the command line by using the VSCode debug dropdown menu and selecting the configured JS app or node and clicking the debugger play button.

Press the green button in your VSCode debugger and it should open a terminal that lists the debug port when connecting to the process.

Debugger listening on port 38569

If all is well, you should now start the node application using the debugger controls in VSCode using the second play button (continue) (continue, step over, step in, exit and stop) .

0


source







All Articles