Vscode: extension.node-debug.startSession failed - linux, nvm and quick launch

Created on 6 Apr 2017  Â·  38Comments  Â·  Source: microsoft/vscode

UPDATE: MAC Users
Lots of users are reporting the same, or similar, errors when using VSCode on a MAC.
The fix for this error is to update the protocol property to 'legacy', in your launch.json file.
"protocol": "legacy"

Root Cause:
nvm (https://github.com/creationix/nvm) provides node via .bashrc, which these launchers to not invoke.

Resolution / Workaround:
Launch code with exposed path for node.

In my case; via gnome-terminal (Which loads .bashrc)

Original Report:

  • VSCode Version:
    Version 1.11.0
    Commit 9122ec4b1068bd391e41974f46a4b54c1b9c90f9
    Date 2017-04-05T21:13:24.700Z
    Shell 1.4.6
    Renderer 53.0.2785.143
    Node 6.5.0
  • OS Version:
    debian_version
    8.7

Steps to Reproduce:

  1. Launch code via Run Program / Quick Launch (ALT + F2)
  2. Attempt to use any form of Debugger

Error Message:
Running the contributed command:'extension.node-debug.startSession' failed.

(edited)
Ensuring node is available in your ENV, and launching from terminal is a valid workaround.
code

Feel free to close this issue if it's expected behavior. This issue was logged as search results for the error message are non-existent.

debug

Most helpful comment

Same problem here after the latest VS code update (1.12.1) on xubuntu; same solution ("protocol": "legacy" to the node launch configuration object).

All 38 comments

When you launch through Run Program, do you open VSCode on a folder or do you just open single files?

Is there anything in the devtools' console (Help > Toggle Developer Tools)?

@chrmarti
Thanks for your response!

(edited)
I am working on a project via folder (File -> Open Folder).

(edited)
I have attached errors captured via Developer Tools (Right Click -> Save As)
vscode-extension.node-debug.startSession.log.tar.gz

Note:
With additional configuration property;
"protocol": "inspector",
The error changes to;

Cannot find runtime 'node' on PATH.

Do you have node installed? You have to have node on your path to use the node debugger.

@roblourens
Thanks for your response.

(edited)
I do have node installed, via nvm (https://github.com/creationix/nvm).

@roblourens @chrmarti
Note: I've updated the initial report.

You can avoid this issue via ALT + F2 if you provide code ..

(amendment)
This was in correct. Providing code . to ALT + F2 still fails. Sorry for the confusion.

And if you type node in the vscode integrated terminal, does it run node successfully?

What does alt+f2 do? I don't see a default keybinding for that.

@roblourens
Thanks again for your response!

Yes. But I think the integrated terminal is literally spawning a new 'session'. ENV variables are available.

Yes, but if the terminal can find node on your path, then the debug adapter should be able to as well.

Can you try launching with "protocol": "legacy"?

@roblourens
ALT + F2 is a bit like Start -> Run (Win + R) in Windows. It's just a launcher.

When invoked via fluxbox, it starts 'fbrun'. But this issue happens with other desktop environments also (xfce, lxde, cinnamon).

@roblourens
(edited)
With additional configuration property;
"protocol": "legacy",
The error changes to;

Cannot find runtime 'node' on PATH.

Ok, so if you launch code with code ., then debugging works, but if you launch code then open a folder, you see "Cannot find runtime 'node' on PATH".

@roblourens
(edited)
Sorry! code . via ALT + F2 doesn't work, contrary to earlier comments (now with amendments).

Additionally:

Cannot find runtime 'node' on PATH

Is only provided if I have a protocol property in my launch configuration. Without this property, the error message is as originally posted.

@roblourens @chrmarti

Further investigations via /proc/\

Though fbrun is the fluxbox implementation, lxde, xfce, cinnamon, and mate all show the same issue with their respective launchers. However; the root cause is the way nvm provides node.

By design; nvm provides my node path via .bashrc. These launchers must not invoke .bashrc.

Long story short;
Combination of quick launch, and nvm (https://github.com/creationix/nvm); results in this situation.

I've updated the initial report to make this clear, and provide a result for anyone else with this issue.

same , @dmblack do you know how to solve it ?

@xsstomy
I updated the initial issue report, upon discovering the fault, to include the steps I needed to solve it.

Briefly; my node path was not available to VSCode, due to the way NVM loads via bashrc - and the fact that 'Quick Launch' doesn't invoke this.

@dmblack
Thanks for your response!

Hi @dmblack, I only started experiencing this since I updated to 1.12.1. I had been able to debug even with nvm before now. This is my first time of encountering this error.

I'm not sure I understood your workaround. I'm running vscode on MacOS Sierra (10.12.4)

@kennasoft I'm also experiencing this as of this morning after VSC seems to have updated. For me adding "protocol": "lagacy" to the launch.json as suggested by @roblourens appears to resolve this. However I'm not sure if this a a bug or expected behaviour.

MacOS El Capitan 10.11.16, VSC 1.12.1

N.B. I'm _not_ using nvm

@superbland that solves it for me too. Thanks;
I'd be surprised if it's expected behaviour, cos the documentation seems to recommend a move away from the legacy protocol.

I meet this before, the environment is OK, I fixed this by disable the Dash[https://marketplace.visualstudio.com/items?itemName=deerawan.vscode-dash] plugin.

Same here on MacOSX 10.12.4 and the newly updated VSCode 1.12.1.

Adding "protocol": "lagacy" solves the issue.

Same problem here, 1.12.1 on macOS 10.12.4,
"protocol": "legacy" in the launch.json solved it.

Same issue here after the latest VS code update; same solution ("protocol": "legacy" to the node launch configuration object).

Same problem here after the latest VS code update (1.12.1) on xubuntu; same solution ("protocol": "legacy" to the node launch configuration object).

Same here: problem solved by updating launch.json

@levicot this works!

all of the sudden it stopped working without legacy protocol. literally was all fine, then i restarted VS, and it broke

@z-vr maybe you restarted VSCode and you were in the middle of debug process?

Same issue here. Had to apply legacy protocol for it to work, worked fine for me on Friday and stopped working over the weekend (when I didn't even turn on the laptop).

macOS 10.12.5

Thanks to all the other users posting feedback on their fixes for MacOS.

I've updated the original report to include this fix - so people don't have to scroll through pages of updates.

Hi all,

Thought I'd chime in. I didn't found the answer of "when on Mac, use the legacy protocol" particularly useful, especially now Node v8.0.0 is out, which doesn't support legacy anymore (I think I'm right in saying that).

I believe the problem in my case - at least - was due to me previously having installed the experimental version of the inspector debugger (and/or the the chrome debugger, not exactly sure which). However, even though they have been removed, they seemed to leave artefacts that were interfering and causing this problem.

So I decided to clean uninstall and reinstall, which fixed it. And this is the key part:

Simply removing /Applications/VS Code and ~/.vscode was not enough. There is also a folder called /Users/<user name>/Library/Application\ Support/Code that needs to be removed.

With this folder removed and a new install of VSCode, it's right back to factory settings. Everything works fine now.

Hoping this helps some future person, because

Manually changed protocol to inspector and it worked for me on node 8.0.

the issue is closed, but can someone explain me how to avoid the problem?
vscode 1.12.2
os: mint 18.1
node 7.2.1

"protocol": "legacy" doesn't solve the problem.

Resolution / Workaround:
Launch code with exposed path for node.

what do you mean " with exposed path "
please example

Guys, I had this problem too just after I installed the Wakatime vscode plugin. I disabled it and it started working .

This issue also seems to crop up if you restart your mac and it automatically reopens VSCode for you. Restarting VSCode corrects the issue.

@dmblack Could you edit @thomassuckow 's response into the top post? While "protocol": "legacy" in the launch.json did allow it to work, Thomas' fix did without having to modify my code. I was having trouble finding relevant info on what that option does so am weary of modifying my code to include it if not necessary.

I will lock this issue since it is too time consuming to follow all the various discussions that were added after the issue has been closed.
Please create new issue and we will investigate.

Was this page helpful?
0 / 5 - 0 ratings