Search code examples
node.jsnvm

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.


Solution

  • 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.