vscode icon indicating copy to clipboard operation
vscode copied to clipboard

fnm/nvm node installs are not found on Windows

Open connor4312 opened this issue 7 months ago • 3 comments

This is a very old issue but I'm failing to find it in search.

  1. Be on Windows
  2. Install Node.js as recommended with winget+fnm on https://nodejs.org/en/download
  3. Open VS Code
  4. Do something that expects node on the path, like starting an MCP server
  5. 🐛 you get an ENOENT

connor4312 avatar May 16 '25 19:05 connor4312

Maybe for VSCode issue they were these ones:

  • https://github.com/microsoft/vscode/issues/246252
  • https://github.com/microsoft/vscode/issues/246293

About ENOENT:

  • https://github.com/Schniz/fnm/issues/1379
  • https://stackoverflow.com/questions/78522961/running-into-a-problem-installing-node-js-via-powershell-using-fnm

Hope that helps.

albertosantini avatar May 17 '25 05:05 albertosantini

@connor4312 as you seem to have a repro can you take the lead to investigate this?

Some questions

Open VS Code

How, from CLI or task bar?

Do something that expects node on the path, like starting an MCP server

Where is the MCP server started, in core or the extension host and how?

bpasero avatar May 17 '25 06:05 bpasero

Oh, I just realised that this is for Windows. We do not resolve any shell environment on that platform because at least back when we implemented shell resolution, Windows did not have any custom profiles, like macOS or Linux has:

https://github.com/microsoft/vscode/blob/6817c06175d99e9de1d31299629c3027e29c6766/src/vs/platform/shell/node/shellEnv.ts#L41-L46

Typically on Windows, all variables are defined globally and thus are always present, irrespective if you launch from UI or terminal.

So it seems to me that this combination of fnm/nvm needs new support for resolving on startup. I.e. a windows implementation of this method:

https://github.com/microsoft/vscode/blob/6817c06175d99e9de1d31299629c3027e29c6766/src/vs/platform/shell/node/shellEnv.ts#L102

bpasero avatar May 17 '25 09:05 bpasero

Verification:

  • Install Node.js as recommended with winget+fnm on https://nodejs.org/en/download
  • if you miss a powershell profile, run if (-not (Test-Path $profile)) { New-Item $profile -Force } in powershell
  • you might need to enable Unrestricted execution policy in powershell
  • add to powershell profile fnm env --use-on-cd --shell powershell | Out-String | Invoke-Expression
  • verify that node can be found when running VS Code from taskbar or launcher

bpasero avatar May 26 '25 06:05 bpasero