Open jschillingApollo opened 1 year ago
What happens if you run nvm use
?
What happens if you run
nvm use
?
Results of nvm use
:
$ nvm use
Found '/c/Users/jschilling/.../.nvmrc' with version <18.13.0>
Now using node v18.13.0 (npm v8.19.3)
That seems to be working properly, at least.
Can you try updating to v0.39.4 and see if that fixes it?
Updated to v0.39.4 and then subsequently v0.39.5 with a new, but still incorrect, result. nvm current
now returns the value none
regardless of what version is currently selected and nvm list
doesn't show the currently selected version either. nvm use
still finds the .nvmrc file in the project and then selects the appropriate version.
$ nvm current
none
nvm debug
also returns the same results as originally posted above, except the current line also shows nvm current: none
.
Presumably nvm_ls_current
also returns none
? if so, what do the following print out?
command which node
nvm_version_dir iojs
node --version
It does indeed. I attempted this with a few node versions that I have installed with nvm and saw the same results. Here's the requested output:
$ nvm_ls_current
none
$ command which node
/c/Users/jschilling/.nvm/versions/node/v18.13.0/bin/node
$ nvm_version_dir iojs
/c/Users/jschilling/.nvm/versions/io.js
$ node --version
v18.13.0
Thanks, that's helpful. What about nvm_tree_contains_path ${NVM_DIR} $(command which node) ; echo $?
?
The output from the requested command is:
$ nvm_tree_contains_path ${NVM_DIR} $(command which node) ; echo $?
0
Hello, I'm also facing this issue.
I have pm2 running under v17, but I always have to add nvm use 17 before being able to access it, which is a bit of a pain. I haven't made any changes to .nvmrc
I think I found a solution, which was in .bashrc
Broken:
PATH=~/bin:/media/sdu1/USER/.nvm/versions/node/v20.10.0/
Working:
PATH=~/bin:/media/sdu1/USER/.nvm/versions/node/v17.9.1/
In my case, 20.10.0 wasn't installed, so it couldn't load it.
I don't have a bin:
folder in my path. I didn't think we should be hardcoding what version of node is being used in our .bashrc
file.
My .bashrc
only has these three lines in relation to nvm
# Load nvm and nvm bash_completion
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Checking the installed versions confirms the versions listed in the nvm list
command are installed (or at least the folders are there);
$ ls ~/.nvm/versions/node/
v12.19.1/ v12.20.2/ v16.17.0/ v18.13.0/
The right version is selected after I run nvm use
based on the version in my project's .nvmrc
file. I can verify that by running node --version
after selecting a version using nvm. The nvm ls
command just doesn't indicate the current selected version like it does on macOS and nvm current
commands doesn't list anything.
Indeed, versions shouldn't be hardcoded like that.
I haven't had a chance to look into this yet, but it's clearly a Windows-specific bug that needs fixing. If someone beats me to it, I'd love to review a PR.
I'm doing some research and this seems like it might be a winpty bug, which is part of git bash.
Specifically:
VERSION="1.2.3"
echo "$VERSION" # prints out 1.2.3
VERSION="$(echo 4.5.6)"
echo "$VERSION" # prints out 4.5.6
node --version 2>/dev/null # prints out whatever the version is
VERSION="$(node --version 2>/dev/null)"
echo "$VERSION" # prints nothing, the var is blank
I'm not sure how to fix this exactly, or how to use -Xallow-non-tty
to get this to work.
I think I found a solution to your example above.
In reference to this SO post, we need to call the node exe explicitly. They mention also that they tried using winpty
and the -Xallow-non-tty
flag with no success but calling the exe explicitly produced results.
I tested it using the example you posted above (with version 18.13.0 selected in my git bash session).
Results:
node --version # prints v18.13.0
VERSION="$(node --version)"
echo $VERSION # prints nothing
VERSION="$(node.exe --version)"
echo $VERSION # prints v18.13.0
I'm not familiar with the codebase for nvm-sh but if someone knows it better, you might be able to update it quicker. I'll poke around in there to see if I can glean where this type of change would need to go.
interesting, thanks. i'll see what's achievable there, since it'd have to be done only for git bash
Operating system and version:
Windows 10, nvm version 0.39.1
nvm debug
output:nvm ls
output:How did you install
nvm
?From the install script in the readme
What steps did you perform?
What happened?
Nvm and the node versions installed as expected, however running the
nvm current
command returns nothing/blank in a Windows 10 & Git Bash environment. It even returns blank in thenvm debug
results posted above.Also
nvm list
andnvm ls
don't notate the currently selected version of Node from the list of installed versions.What did you expect to happen?
Similar to how it operates in our MacOS environments, I would expect
nvm current
to show the currently selected Node version andnvm list
andnvm ls
to notate the currently selected Node version from the list of installed versions.Is there anything in any of your profile files that modifies the
PATH
?Not that I can see. The
.bashrc
file alters the NVM_DIR variable and exports it but that is all.