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

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.


Changing from

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

To

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

Worked for me :)


Create a file called

~/.curlrc

In it insert one line

-k

Then try again.


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
    

Tags:

Node.Js

Nvm