Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

node.js

nvm

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.

like image 867
eComEvo Avatar asked Oct 20 '14 23:10

eComEvo


People also ask

What is NVM command?

NVM stands for Node. js Version Manager. The nvm command is a POSIX-compliant bash script that makes it easier to manage multiple Node. js versions on a single environment. To use it, you need to first install the bash script, and add it to your shell's $PATH .

Does NVM work on Linux?

Node Version Manager (NVM in short) is a simple bash script to manage multiple active node. js versions on your Linux system. It allows you to install multiple node. js versions, view all versions available for installation and all installed versions on your system.


2 Answers

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.

like image 145
Jeffrey Martinez Avatar answered Sep 20 '22 08:09

Jeffrey Martinez


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 
like image 21
Gerhard Burger Avatar answered Sep 19 '22 08:09

Gerhard Burger