jorgebucaran / nvm.fish

The Node.js version manager you'll adore, crafted just for Fish
https://git.io/nvm.fish
MIT License
2.06k stars 69 forks source link

does not seem to persist to vsc #221

Closed jakubdonovan closed 5 months ago

jakubdonovan commented 5 months ago

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 commented 5 months ago

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:

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 commented 5 months ago

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 commented 5 months ago

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