vitest-dev / vscode

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

v0.8+ is broken #357

Closed andrewl913 closed 4 months ago

andrewl913 commented 4 months ago

Describe the bug

v0.8 of the extension is broken.

v0.6 is latest working version

Reproduction

Install any version v0.8 and above.

Running on MacOS Montery

Output

: Vitest failed to start: 

r
    at ChildProcess.u (/Users/[redacted]/.vscode/extensions/vitest.explorer-0.8.0/dist/extension.js:13:331)
    at ChildProcess.emit (node:events:517:28)
    at emit (node:internal/child_process:944:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
``

Version

0.8

Validations

github-actions[bot] commented 4 months ago

Hello @andrewl913. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction will be closed if they have no activity within 3 days.

guysympoly commented 4 months ago

Hi, @andrewl913, @sheremet-va

TL; DR - I had node v16.x.x installed (globally), updated to v20.x.x and it was fixed.

I had the same issue in Windows (v 0.8.0 to 0.8.3), at first (0.8.0) I though it was this https://github.com/vitest-dev/vscode/issues/356, but the problem persisted. I tried to make sense out of it and then I noticed the logs of the extension, specifically this line:

[INFO 7:11:22 PM] [API] Starting Vitest process with Node.js: C:\Program Files\nodejs\node.EXE

I use fnm to manage node versions, currently using v20.10.0, but this log made me speculate, so I launched said C:\Program Files\nodejs\node.EXE and saw that it was version 16.x, so naturally I downloaded the official latest LTS (v20.12.2), restarted VSCode, and the extension started working.

So, I guess it was all about the resolution of node's executable, being an older version. (For me at least).

sheremet-va commented 4 months ago

TL; DR - I had node v16.x.x installed (globally), updated to v20.x.x and it was fixed.

Yes, the extension now uses the local Node.js executable resolved relative to the workspace root using which command:

https://github.com/vitest-dev/vscode/blob/6a103f7fd395c53575af01c49e37be3dd21fd446/src/utils.ts#L93

Make sure your Node.js version is matching minimal Vitest requirements (Node >=v18.0.0). Maybe we need to have it built-in.

guysympoly commented 4 months ago

Yes, the extension now uses the local Node.js executable resolved relative to the workspace root using which command:

I did actually look into it. It has to be git-bash (windows) vs CMD. Running node -v on git-bash points to the version installed by fnm, and running in CMD points to the one in Program Files.

theClarkSell commented 4 months ago

FWIW I ran into this as well. macos using nodenv. We were already running 18 in our project. I'm not sure what version it picked up, but once I set a global 0.8 worked. Something I need to look into more.