Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find 'node' executable when using VSCode on Windows with fnm (Fast Node Manager) #486

Closed
4 tasks done
jpierson-at-riis opened this issue Oct 3, 2024 · 8 comments

Comments

@jpierson-at-riis
Copy link

Describe the bug

I'm unable to use this extension in VSCode due to the extension not being able to find the node executable. In my environment I use fnm which is configured properly to run in all of my shells. Other plugins such as those for Jest and the VSCode debuger have had similar issues with version managers but normally there is a way to configure the extension to resolve the node path through a specific configuration.

Reproduction

  1. Ensure no other Node.js installations exist
  2. Install fnm (winget install "Schniz.fnm")
  3. Install VSCode
  4. Open a project which uses vitest
  5. Install the vitest-dev extension through the extension in VSCode

Output

[Error 8:27:31 AM] [Error Error] Unable to find 'node' executable.
Make sure to have Node.js installed and available in your PATH.
Current PATH: 'C:\Program Files\OpenSSH\;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Oracle\Java\java8path;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\IBM\Client Access\Emulator;C:\Program Files (x86)\IBM\Client Access\Shared;C:\Program Files (x86)\IBM\Client Access\;C:\Windows\CCM;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files\Perforce\;C:\Program Files\Seq\;C:\Program Files\Seq\Client\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\dotnet\;C:\Program Files\PuTTY\;C:\Program Files\PowerShell\7\;C:\Users\myuser\AppData\Local\Microsoft\WindowsApps;C:\Users\myuser\.dotnet\tools;C:\Users\myuser\AppData\Local\Microsoft\dotnet\;C:\Users\myuser\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\myuser\AppData\Local\Programs\Git\cmd;C:\tools\java-1.8.0-openjdk-1.8.0.352-2.b08.redhat.windows.x86_64;C:\Users\myuser\.jabba;C:\Users\myuser\.jabba\jdk\17.0.1-redhat\bin;C:\tools\node-v18.12.0-win-x64-disabled;C:\tools\node-v16.15.0-win-x64-disabled;C:\tools\node-v16.14.0-win-x64-disabled;C:\tools\node-v12.14.1-win-x64-disabled;C:\Users\myuser\AppData\Local\nvs;C:\tools\python-3.10.4-embed-amd64;C:\tools\python-2.7.16.amd64-pdb;C:\tools\apache-maven-3.9.2\bin;C:\tools\apache-maven-4.0.0-alpha-5\bin;C:\tools\maven;C:\Program Files\Azure Data Studio\bin;C:\Users\myuser\AppData\Local\Microsoft\WinGet\Packages\Schniz.fnm_Microsoft.Winget.Source_8wekyb3d8bbwe\;C:\tools\libwebp-1.3.2-windows-x64\bin;C:\Users\myuser\.dotnet\tools'.

Version

v1.2.18

Validations

@jpierson-at-riis
Copy link
Author

Ok, so searching the issues didn't turn up any results for me initially but after briefly reading through the README.md I see the the vitest.nodeExecutable option that is provided. For version managers which determine the version through the shell context though I'm not sure how to make this work effectively for a large number of separate projects which may use different versions of node.

Based on my limit knowledge on this extension, one option might be to default to a single version of node on the system for the purpose of running this extension by taking advantage of the vitest.nodeExecutable to hard code a path to a specific version of node installed through fnm. I've had issues doing a similar thing with a Jest extension in that it was sensitive to different versions of node across projects. Another option would be to potentially have vitest launch node on Windows with something similar to ShellEexecute or through the default shell (Powershell on Windows 10+) instead of running the node executable directly.

@jpierson-at-riis
Copy link
Author

It appears that this may be a similar issue to the on pointed out in #381 which didn't seem to come to a great conclusion but it also looks like some related discussion is happening in #383 but with a different focus on on intermittent issues.

@sheremet-va
Copy link
Member

Would this option fix your issue? #490

@mrmckeb
Copy link

mrmckeb commented Oct 10, 2024

Hi @jpierson-at-riis, we're using this extension with fnm, but my team are all on macOS. It may be a Windows path issue?

We also use fnm with --use-on-cd which may also fix your issue.

@jpierson-at-riis
Copy link
Author

jpierson-at-riis commented Nov 6, 2024

@mrmckeb, I would also guess that this issue is related to how the node executable is executed as a process and perhaps this is different for VSCode with the vitest-dev textension between Windows and MacOS. I would guess that on MacOS that you may be specifying the --use-on-cd option within bashrc or something like that? On Windows use the following commands in my profile.ps1 file but this only works if node is attempted to be executed using Powershell as opposed to a standalone processes.

# Setup FNM
fnm env --use-on-cd | Out-String | Invoke-Expression
fnm --version

@jpierson-at-riis
Copy link
Author

@sheremet-va, it looks like by setting the new vitest.shellType config option to terminal that this may have solved this issue for me. I didn't need to set vitest.terminalShellPath or any of the other related options at all and it seems that everything is now working as expected. I'm guessing that my default shell is probably set to pwsh and thus this works without setting a path because normally fnm won't work from a normal cmd console.

Thank you for the fix and also for alerting me of it above! 🍻

@jpierson-at-riis
Copy link
Author

@sheremet-va , I can create a new issue perhaps but I had just noticed that while the shellType option does seem to get the test runner to work in VSCode, the feature to debug a test does not seem to work still. Below is the error message that I'm seeing.

An error occurred attempting to run tests: Error: Unable to find 'node' executable. Make sure to have Node.js installed and available in your PATH. Current PATH: ...

@sheremet-va
Copy link
Member

@sheremet-va , I can create a new issue perhaps but I had just noticed that while the shellType option does seem to get the test runner to work in VSCode, the feature to debug a test does not seem to work still. Below is the error message that I'm seeing.

An error occurred attempting to run tests: Error: Unable to find 'node' executable. Make sure to have Node.js installed and available in your PATH. Current PATH: ...

Feel free to open a new issue

@github-actions github-actions bot locked and limited conversation to collaborators Nov 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants