-
Notifications
You must be signed in to change notification settings - Fork 24
The extension can't find node (due to use of nvm), and there's no setting to provide the path manually #101
Comments
In the case of nodenv (which I use in preference to nvm) I simply configure nodenv in a terminal, then launch VSCode from there, where it picks up the proper binary paths from the shell. This is on Ubuntu and bash, though. |
I'm using nvm and bash on Ubuntu and experience the same issue. |
Hey all. The actual runner is in a depency (jest-editor-support). I think the issue is because the process runs in the default shell for your OS. Which I think is/bin/sh for you guys. I'm guessing the error you're experiencing is because your PATH doesn't include a directory to the location of node.js for your default shell. Can you confirm whether this reasoning is correct? It would take a bit of effort to replicate this on my end. |
Thanks for the question @rossknudsen
Although I am using zsh, it is configured as the default shell
I also checked whether any other user has a different shell configured ("just in case"), and there is no other shell:
So this makes me think the "default shell" part of the hypothesis might not be the case.
@rossknudsen this is the part of your hypothesis that I wonder if it could still apply to me. My nvm at the command line comes from loading the zsh nvm plugin in my However, I'm still wondering about your case, @SplitThePotCyrus, as you mentioned bash on Ubuntu. That means it's for sure the default shell, right? — unless you changed default shell? And what about nvm, how/where did you install it? |
@darynmitchell have you tried the community Jest test extension? It uses the same dependency and I'm interested to know if that works under the same conditions. |
Yes, it was my default shell. However my main issue was: I created and ran a VM with Ubuntu. Then by accident, using an external terminal, I logged in (SSH) to the VM and noticed that nmv, node etc. was not working in that shell. It turns out that VS Code starts an interactive non-login shell, hence all paths etc. are added to ~/.bashrc when installed from terminal inside VS Code. The extension does not seem to use the same type of shell as VS Code is using, therefore was using a shell that looks at ~/.bash_profile (which was empty) When I then added the following to my ~/.bash_profile, then the extension recognized my installed node and started working.
I think one hint to the issue might be that the extension is using other means of starting a shell than VS Code is currently using. Don't know if this helps in any way. |
The extension calls |
I'm getting the feeling that the issue at hand here is more to do with machine setup, or the way you are running Code rather than the extension itself. Basically it appears that the PATH variable does not include the configured path to node and that is because nvm is not running when the Child_Process is being spawned - probably because the shell profile that should be executed, is not. You could debug this if you want to, and I'm happy to provide guidance, but I'd either have to try and replicate your environment or guess. So, you could pull down the extension codebase, branch from master and add some debugging statements that would write out the value of |
Thanks for your questions @rossknudsen. I will look for an opportunity in my schedule (hopefully in the next two weekends) to give some time to trying again from scratch and update here on what I find. |
Do I have a related problem or should I raise a different issue? On Mac, with "Path to Jest" set as
|
This is why I load nvm in my |
After bashing my head against this wall on MacOS for the better part of a day, I just added the nvm node version bin to the path in the jest command line.
|
This resolved the issue on MacOS 11 with zsh! Thank you! |
After updating to Mac OS Monterey, VS Code's debugger was giving us a |
You saved me!! In addition,
So It is good for you to use like this when you are using zsh:
(ref: https://superuser.com/a/901485) You can handle Hope you all having happy testing with vscode-jest! |
None of this works in remote vscode when debugging. It works when running but debugging throws the error before anything else |
in my case, in Linux machine this worked, but I imagine it would work for OSX as well:
Just replace |
Describe the bug
A clear and concise description of what the bug is:
I don't have node installed directly, instead I use nvm.
node
is available in my zsh shell path in vscode terminal:and
However...
When the extension tries to load tests (i.e. initially l when I open the sidebar, or when I click 'Reload'), output displays error:
I added a log file to the Jest Test Explorer settings and it outputs:
To Reproduce
Steps to reproduce the behavior:
node
, so node is not installed under/usr/bin/...
Expected behavior
Best: The extension should automatically use the node version that the project is already using
Workaround: The extension should provide a setting so I can manually set the path to node?
Desktop (please complete the following information):
Additional context
plugins+=(nvm)
The text was updated successfully, but these errors were encountered: