Thursday, 13 April 2017

VSCode - Can't run node in vagrant image with integratedConsole

I'm trying to get VSCode setup so I can compile and debug a node application inside a vagrant VM. Thus far I've got it to the point where one launch task can ssh into the vagrant image, run gulp to build and then node to execute the task. But the later part has to be done with the integrated terminal, rather than the integrated console. If I let it use the console, it simply shows the command to be executed in the Debug Console view (in yellow) and nothing else. The node process isn't run on the VM.

I have a second launch task that can then be used to attach the debugger to the running instance. Ideally that would be possible with a single launch task, but I can't figure that out (although that isn't the main element of this issue).

  • VSCode Version: 1.10.2
  • OS Version: Ubuntu 16.10

Steps to Reproduce:

  1. Vagrant VM with node installed
  2. launch.json configured thus

.

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Build and Run",
            "outFiles": [],
            "preLaunchTask": "default",
            "port": 15858,
            "console": "integratedTerminal",
            "runtimeExecutable": "/usr/bin/vagrant",
            "runtimeArgs": [
                "ssh",
                "-c",
                "cd /proj/core/dist; node --debug=0.0.0.0:5858 index.js"
            ]
        },
        {
            "type": "node",
            "request": "attach",
            "name": "Attach",
            "outFiles": [],
            "port": 15858,
            "address": "localhost",
            "localRoot": "${workspaceRoot}",
            "remoteRoot": "/proj/core"
        }
    ]
}

tasks.json for the gulp command:

{
    "version": "0.1.0",
    "command": "vagrant",
    "isShellCommand": true,
    "args": [
        "ssh",
        "-c",
        "cd /proj/core; gulp"
    ],
    "tasks": [
        {
            "taskName": "default",
            "args": [],
            "isBuildCommand": true,
            "problemMatcher": [
                "$lessCompile",
                "$tsc",
                "$jshint"
            ]
        }
    ]
}

If I change the command to simply echo "hello"; (on the local machine) then it executes and shows the response in the debug console as expected, but using vargrant's ssh command at all just doesn't do anything. Checking it to integratedTerminal does allow it to run (although as I say, I need another launch config to attach to the process).

Does anyone have such a setup already?



via Allan Jardine

No comments:

Post a Comment