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

does not seem to persist to vsc #221

Closed
jakubdonovan opened this issue Mar 26, 2024 · 3 comments
Closed

does not seem to persist to vsc #221

jakubdonovan opened this issue Mar 26, 2024 · 3 comments

Comments

@jakubdonovan
Copy link

jakubdonovan commented Mar 26, 2024

Installed nvm.fish and set my nvm_default to lts (20) but VSC thinks that I use 20.11.1 even though my version for that project is set to 19.0.0 via .nvmrc. When I run node -v in the vsc terminal window, it returns 19.0.0 but when I try to run the Truffle for VSCode extension, it tells me that 20.11.1 is installed therefore the extension fails to run. I'm not entirely sure if this is caused by something in my installation but their documentation claims that nvm is fully supported so I didn't know where else to ask.

Screenshot 2024-03-26 at 18 21 04

EDIT: installing 18.19.1 and setting it as the nvm_default fixes the issue. VSC or truffle seems to for some reason prioritise the nvm_default over the version set for that project.

@jorgebucaran
Copy link
Owner

I'm not familiar with Truffle and have no knowledge of its function or whether it conflicts with nvm.fish. It's unlikely, but possible. Anyway, here's what should happen if you set the nvm_default_version and have also an .nvmrc file in your project's root directory:

  • When you change directories (cd) into that directory, nothing will happen automatically. nvm.fish isn't designed to switch Node versions automatically, nor will it be. If you run nvm use, nvm.fish will read the .nvmrc file and switch to the Node version specified there.
  • Whether you run nvm use or not, when you open a new shell, nvm.fish will default your Node version to whatever is set as nvm_default_version, as per the documentation.

That's the extent of what nvm.fish is programmed to do. If that's not what happened, let me know and let's look into it.

Note: nvm.fish != nvm. As stated in the README, nvm.fish was specifically designed for Fish users and built from scratch in Fish.

@jorgebucaran
Copy link
Owner

When you open a new terminal window, nvm defaults your Node version to $nvm_default_version. This behavior is independent of your .nvmrc file. The .nvmrc file kicks in when you run nvm use (without specifying a version). Here, nvm.fish sets the Node version to the one specified in your .nvmrc file. Creating another terminal window resets this, reverting to the version specified in $nvm_default_version, as initially described.

@jakubdonovan
Copy link
Author

When you open a new terminal window, nvm defaults your Node version to $nvm_default_version. This behavior is independent of your .nvmrc file. The .nvmrc file kicks in when you run nvm use (without specifying a version). Here, nvm.fish sets the Node version to the one specified in your .nvmrc file. Creating another terminal window resets this, reverting to the version specified in $nvm_default_version, as initially described.

I ran the following:
set --universal nvm_default_version 20.11.1
and then added an .nvmrc to the root of the project

v20.11.1

restarted vsc shell
Screenshot 2024-03-27 at 11 31 33

The issue persisted. I believe that the issue was caused by my original installation of node and npm as running

sudo rm -rf /usr/local/bin/npm
sudo rm -rf /usr/local/bin/node

fixed the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants