vitest-dev / vscode

VS Code extension for Vitest
https://vitest.dev/vscode
MIT License
729 stars 79 forks source link

NVM support / Improve error message if node executable cannot be found #381

Closed fehmer closed 2 months ago

fehmer commented 2 months ago

Describe the bug

i'm using ubuntu linux and don't have a nodejs version installed globally but use nvm.
On opening vscode there is a popup There was an error during Vitest startup. and the output is this:

[INFO 1:06:28 PM] [v0.10.2] Vitest extension is activated because Vitest is installed or there is a Vite/Vitest config file in the workspace.
[INFO 1:06:29 PM] [API] Running Vitest: v1.6.0 (vitest.config.js), v1.6.0 (vitest.config.js)
[Error 1:06:30 PM] [Error Error] spawn ENOTDIR
Error: spawn ENOTDIR
    at ChildProcess.spawn (node:internal/child_process:414:11)
    at spawn (node:child_process:799:9)
    at /home/user/.vscode/extensions/vitest.explorer-0.10.2/dist/extension.js:18:186

Best solution would be to use the default node version from nvm. If this is not possible improve the error message like Cannot find node executable, set vitest.nodeExecutable configuration in your workspace or make sure node is installed at <expected-path>

Reproduction

Output

[INFO 1:06:28 PM] [v0.10.2] Vitest extension is activated because Vitest is installed or there is a Vite/Vitest config file in the workspace.
[INFO 1:06:29 PM] [API] Running Vitest: v1.6.0 (vitest.config.js), v1.6.0 (vitest.config.js)
[Error 1:06:30 PM] [Error Error] spawn ENOTDIR
Error: spawn ENOTDIR
    at ChildProcess.spawn (node:internal/child_process:414:11)
    at spawn (node:child_process:799:9)
    at /home/user/.vscode/extensions/vitest.explorer-0.10.2/dist/extension.js:18:186

Version

0.10.2

Validations

garyking commented 2 months ago

Is this a new issue? I just installed the Vitest extension a few days ago, and I get this error every time I open a workspace in VSC. Is there a previous version of this extension I can roll back to for now, that doesn't have this issue?

Edit: Okay, I can see that the issue starts with v0.8.0 of this extension. So I'm using 0.6.3 for now. Presumably caused by this change.

Is there something I can change to fix this on my end? I've got Node installed globally on my Mac, v20.11.0, at /usr/local/bin/node. I don't use nvm.

The funny thing is the extension still seems to work fine.

sheremet-va commented 2 months ago

I also use nvm and it's working fine. The reproduction is not enough. What does which node return when you run it in a terminal? What OS are you using?

fehmer commented 2 months ago

Thanks for the reply. The issue was how I openened vscode. Opening it from a commandline works.

garyking commented 2 months ago

Thanks for the reply. The issue was how I openened vscode. Opening it from a commandline works.

This put me on the right path... I've posted my issue in #383.