nvm ls-remote command results in "N/A"

I'm trying to install Node with nvm, but when I type any version it's not available. When I type nvm ls-remote I just just get "N/A".

I'm able to access the Internet, so I can't figure what could be going on.

80068 次浏览

Update with comment from LJHarb, who maintains nvm.sh

LJHarb suggests that a typical problem causing this is that "the SSL certificate authorities installed in your system have gone out of date". Checking this and trying to fix this would be a better first step.

In the case where you believe there is a problem on the nvm.sh side, LJHarb asks that users file a bug on nvm.sh's issue tracker.

Feel free to see the original text in the comments section.

Also, I'd like to point out that the below solutions are intended as workarounds only to be used temporarily if you're really in a bind. Permanently modifying the exported mirror or the nvm.sh script itself is not recommended.

Edit: Found easier fix

You can export the non https version of the mirror it uses to grab the stuff:

export NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist

Then nvm works

Pre edit

Had the same problem just now.

Looks like by default it tries to use curl if it's available on your system.

I assume you're on linux also, so try running curl $NVM_NODEJS_ORG_MIRROR and see if you get the same error I did:

curl: (77) error setting certificate verify locations:
CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none

Maybe some cert is expired or otherwise misconfigured (or someone's doing something nasty), until it's fixed, if you don't mind going around the security issue, you can find the nvm.sh file (should be at ~/.nvm/nvm.sh if you followed the install info), and you can add a -k on line 17 after the curl, so it looks like this:

-- nvm.sh --
nvm_download() {
16  if nvm_has "curl"; then
17    curl -k $*
18  elif nvm_has "wget"; then
19    # Emulate curl with wget
...
}

Don't forget to restart your shell, then try nvm ls-remote. Assuming the fix worked, you should be able to use nvm now.

It seems the '/' is missing from the end of the url, that is why the 301 permanently moved message. So changing the link in nvm.sh from

http://nodejs.org/dist

to

http://nodejs.org/dist/

makes it work.

Most likely this is caused by curl not being able to use certificates for https urls (verify with curl $NVM_NODEJS_ORG_MIRROR). Instead of using the http url as workaround, it is better to fix curl by pointing it to the appropriate CA bundle (source1, source2). Add the following line to your .bashrc:

  • Ubuntu (assuming you have the ca-certificates package installed)

    export CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
    
  • RHEL 7

    export CURL_CA_BUNDLE=/etc/pki/tls/certs/ca-bundle.crt
    

I was running into this problem when using Vagrant 1.7.1 running a Ubuntu 14.04 box under Virtual Box 4.3.30 on Windows 7. I tried suggestions above and nothing worked for me. I found this post over here that was related to the Curl error I was getting when trying to run: curl $NVM_NODEJS_ORG_MIRROR The error was: curl: (7) Couldn't connect to server I was able to follow a suggestion on that post and then once I restarted my Vagrant box with a vagrant reload I was able to run nvm ls-remote and see a list of versions of node and install. Here is what I did on the vagrant box: cd /etc/

sudo nano hosts

changed 127.0.0.1 localhost

to:

0.0.0.0 localhost

Hope this helps anyone with the same issue. Thanks@ Truong Nguyen

I had this same problem, but none of the other solutions helped. curl -v $NVM_NODEJS_ORG_MIRROR/ showed TLS 1.2 and no problem with certs. When I tried which curl, it turns out that I had an anaconda3/bin directory in my PATH, which has it's own version of curl (not sure why they need that). Once I fixed my path, nvm ls-remote worked just fine. Hope this helps save someone else some frustration.

If you are using nvm behide a proxy you need set proxy config to curl

edit or create the file ~/.curlrc and add this line with your proxy

echo 'proxy=http://<proxy-user>:<proxy-pass>@<proxy-url>:<proxy-port>' >> ~/.curlrc

if your proxy does not need a user and password, you can use it:

echo 'proxy=http:<proxy-url>:<proxy-port>' >> ~/.curlrc

For me, this will work

nvm alias default node points "default" at the latest installed Node version (8.11.1).

It's work for me in my linux:

export NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist

Changing from

export NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist/

To

export NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist/

Worked for me :)

For others like me who land here after a search:

I had the same issue today on Ubuntu, but the cause turned out to be that the /etc/ssl/certs/ca-certificates.crt file was completely empty.

The solution was to run:

sudo update-ca-certificates

My scenario could be rare, but just want to add another data point to this thread:

Because of my local setup issue, I don't want to install curl, and I explicitly set an alias for curl to warn myself from installing it in the future, which results in the nvm believing I have curl available and use curlto download. It worked after I removed my alias.

Solution

check explicitly if your curl or wget is usable.

Create a file called

~/.curlrc

In it insert one line

-k

Then try again.

I was having this issue lately. Changing to http://nodejs.org/dist/ did not work for me because it redirecrs to https and that results in NA from nvm ls-remote. So what I've done was:

sudo update-ca-certificates

Then I edited ~/.nvm/nvm.sh and changed

http://nodejs.org/dist to https://nodejs.org/dist/ (added https and "/" to avoid redirects) and it worked

On Ubuntu server, the interfaces aren't setup with DHCP by default. I forgot about this and after I installed nvm, I rebooted which lost network connectivity and didn't realize it. I know that you had network connectivity, but I am posting this as something for posterity to check. Stupid simple thing that can be easily forgotten/missed.

I solved my problem by manually upgrading nvm to the latest version

(
cd "$NVM_DIR"
git fetch --tags origin
git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
) && \. "$NVM_DIR/nvm.sh"

For nvm-windows use nvm list available

I had the same problem on WSL2. I also have an https_proxy environment variable set to my company's https_proxy server.

When working inside the company VPN, this did not work since (I believe) WSL2 have a problem using the proxy settings correctly.

Outside the company VPN, un-setting this environment variable, fixed the problem.

so (outside the VPN):

unset https_proxy

and then

nvm ls-remote --lts

worked.

I found a workaround that allowed me to do what I wanted even though nvm list available still isn't working after trying everything on this list.

It might be an old version of curl but working on a server shared with others and not allowed to update that until I wait a few days for approval.

Ultimately I went to: https://nodejs.org/download/release/ I found the newest version of node I was looking to install, which was 16, located here: https://nodejs.org/download/release/latest-v16.x/

Then simply ran:

nvm install v16.16.0

And the install worked fine even if I couldn't pull available versions via nvm!

In my case the problem was with dns; for where I work dns is set automatically and when I ran curl -v $NVM_NODEJS_ORG_MIRROR/ it lead to Could not resolve host: nodejs.org and ping nodejs.org ran to Temporary failure in name resolution. So I changed /etc/resolv.conf and added

nameserver 8.8.8.8
nameserver 8.8.4.4

and then nvm install --lts started working.