vitest-dev / vscode

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

Failed to get Node.js version #413

Closed bennycode closed 1 month ago

bennycode commented 1 month ago

Describe the bug

On VS Code startup I am receiving an error from the "vitest.explorer" extension.

Screenshot:

image

When I run /home/bennycode/.nvm/versions/node/v20.10.0/bin/node --version on my Terminal it shows v20.10.0.

Reproduction

Output

[INFO 12:48:45 PM] [v0.12.0] Vitest extension is activated because Vitest is installed or there is a Vite/Vitest config file in the workspace.
[Error 12:48:45 PM] [API] Failed to get Node.js version from /home/bennycode/.nvm/versions/node/v20.10.0/bin/node
[Error 12:48:45 PM] [Error Error] Failed to get Node.js version

Error: Failed to get Node.js version
    at wf (/home/bennycode/.vscode-server/extensions/vitest.explorer-0.12.0/dist/extension.js:18:4670)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async _f (/home/bennycode/.vscode-server/extensions/vitest.explorer-0.12.0/dist/extension.js:20:569)
    at async /home/bennycode/.vscode-server/extensions/vitest.explorer-0.12.0/dist/extension.js:18:4126
    at async Promise.all (index 0)
    at async no (/home/bennycode/.vscode-server/extensions/vitest.explorer-0.12.0/dist/extension.js:18:4161)
    at async wr.defineTestProfiles (/home/bennycode/.vscode-server/extensions/vitest.explorer-0.12.0/dist/extension.js:26:2671)
    at async wr.activate (/home/bennycode/.vscode-server/extensions/vitest.explorer-0.12.0/dist/extension.js:26:5698)
    at async od (/home/bennycode/.vscode-server/extensions/vitest.explorer-0.12.0/dist/extension.js:26:783)
    at async a.n (/home/bennycode/.vscode-server/bin/89de5a8d4d6205e5b11647eb6a74844ca23d2573/out/vs/workbench/api/node/extensionHostProcess.js:145:6361)
    at async a.m (/home/bennycode/.vscode-server/bin/89de5a8d4d6205e5b11647eb6a74844ca23d2573/out/vs/workbench/api/node/extensionHostProcess.js:145:6324)
    at async a.l (/home/bennycode/.vscode-server/bin/89de5a8d4d6205e5b11647eb6a74844ca23d2573/out/vs/workbench/api/node/extensionHostProcess.js:145:5781)
[Error 12:48:45 PM] [API] Failed to get Node.js version from /home/bennycode/.nvm/versions/node/v20.10.0/bin/node
[Error 12:48:45 PM] [API] Failed to get Node.js version from /home/bennycode/.nvm/versions/node/v20.10.0/bin/node

Version

0.12.0

Validations

maxdzin commented 1 month ago

Same. It worked fine for VSCode v1.89 but started to drop the same error with the latest v1.90 update. I also use nvm.

sheremet-va commented 1 month ago

I cannot reproduce this locally, but I added some logs in 0.12.1. If you have anything new in the "Output" channel, please share.

maxdzin commented 1 month ago

Thank you, @sheremet-va With the update of Vitest extension to v0.12.1 it started working. I also updated the latest node LTS version, v20.14.0 (previous was v20.13.1), so it might be the case when some paths were updated or something. There are output logs for the updated Vitest extension:

[INFO 5:03:33 PM] [v0.12.1] Vitest extension is activated because Vitest is installed or there is a Vite/Vitest config file in the workspace.
[INFO 5:03:47 PM] [API] Running Vitest v1.6.0 (dashboard/vitest.config.ts) with Node.js: /home/***/.nvm/versions/node/v20.14.0/bin/node
[Worker] Running with compatibility version `4`
[INFO 5:04:32 PM] [API] Vitest v1.6.0 (dashboard/vitest.config.ts) process 38056 created
[INFO 5:07:46 PM] Running 1 file(s): tests/unit/init.test.ts
sheremet-va commented 1 month ago

This should be fixed in 0.12.2 for everyone in https://github.com/vitest-dev/vscode/commit/5e3f10d7a309fa383d956c2e554f290f776e12d3, we don't throw an error anymore if the version was not returned.

bennycode commented 1 month ago

@sheremet-va it looks like the error is not shown then any longer but does it actually fix the cause of the extension not finding the Node version? I noticed that when the error appears I am not able to use the extension via sidebar buttons on my test code files.

sheremet-va commented 1 month ago

I noticed that when the error appears I am not able to use the extension via sidebar buttons on my test code files.

You should be able to see the reason in the Output panel. You can open it via "Vitest: Show Output Channel" command.