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

fix: "Unable to obtain node version." in git bash windows #3419

Closed
wants to merge 1 commit into from

Conversation

svihpinc
Copy link

@svihpinc svihpinc commented Sep 2, 2024

$ nvm install-latest-npm
Attempting to upgrade to the latest working version of npm... Unable to obtain node version.

Fixes "Unable to obtain node version." error in git bash (for windows). running npm --version without command does not print anything to stdout.
running nvm_echo "$(command where node)" gives the windows path, like so: C:\Users\user\portable_apps\.nvm\versions\node\v18.20.2\bin\node.exe. It might be the cause.

Its a stretch, but this could also be related to #2780

$ nvm install-latest-npm
Attempting to upgrade to the latest working version of npm...
Unable to obtain node version.
@ljharb
Copy link
Member

ljharb commented Sep 2, 2024

That doesn’t make sense - if node --version prints nothing, how does any node command work?

@ljharb
Copy link
Member

ljharb commented Sep 2, 2024

Either way, the windows version of node shouldn’t be in play here, since if you’re using nvm, the entire point is to install a no -windows version of node.

@svihpinc
Copy link
Author

svihpinc commented Sep 2, 2024

I haven't been able to figure out why it works with command either.

There's only nvm node installed on my system, the is no windows version, other than the ones installed by nvm.

where node prints the windows path, instead of the Linux like path, eg: /c/Users/user....

@ljharb
Copy link
Member

ljharb commented Sep 2, 2024

ah, well that's expected since where is windows-only - which node presumably would print the linux-like path.

@ljharb
Copy link
Member

ljharb commented Sep 2, 2024

what does type -a node print out?

@svihpinc
Copy link
Author

svihpinc commented Sep 3, 2024

You're right

$ which node
/c/Users/sriram1001/portable_apps/.nvm/versions/node/v18.20.2/bin/node

I'm not sure what winpty is, I get the following output

$ type -a node
node is aliased to `winpty node.exe'
node is /c/Users/sriram1001/portable_apps/.nvm/versions/node/v18.20.2/bin/node

@ljharb
Copy link
Member

ljharb commented Sep 3, 2024

so that alias - probably in a shell profile file - is what's causing the problem.

@svihpinc
Copy link
Author

svihpinc commented Sep 3, 2024

I only have one ~/.bash_profile. Does git bash itself create any configs? I'll try to find where this is set

@svihpinc
Copy link
Author

svihpinc commented Sep 4, 2024

Looks like its an alias added by git bash. Adding unalias node to ~/.bash_profile worked for me.

https://stackoverflow.com/a/44835766/8478131

Thanks @ljharb

@svihpinc svihpinc closed this Sep 4, 2024
@svihpinc svihpinc deleted the patch-1 branch September 4, 2024 16:04
@ljharb ljharb added OS: windows shell alias clobbering Anything dealing with users shadowing builtins with aliases or functions. labels Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS: windows shell alias clobbering Anything dealing with users shadowing builtins with aliases or functions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants