87

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.

2

20 Answers 20

109

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.

17
  • 6
    I get no curl error. Instead I get an HTML error doc for 301 moved permanently. When I echo that string, I get https://nodejs.org/dist which is absolutely correct from what I can tell.
    – eComEvo
    Oct 21, 2014 at 1:44
  • 1
    BTW, you original solution to add -k after curl solved the problem. The export solution did not work. Thanks for your help!
    – eComEvo
    Oct 21, 2014 at 1:59
  • 8
    I'm the nvm.sh maintainer. Please DO NOT edit nvm.sh directly. If you have SSL issues, fix your SSL issues.
    – LJHarb
    Jun 7, 2016 at 23:28
  • 2
    Typically it's that the SSL certificate authorities installed in your system have gone out of date. In this specific case, the SSL certificate configurations on nodejs.org and iojs.org were temporarily altered - ie, it was out of user control, and was fixed without user intervention. In general in these situations, please file issues on nvm.sh rather than posting a random Stack Overflow question, and you'll get a fast response with far more context than you can get here.
    – LJHarb
    Jun 9, 2016 at 5:53
  • 1
    @LJHarb Added your input to the answer. Hopefully that captures what you're saying. If not, feel free to edit and add as well :) Jun 9, 2016 at 14:58
37

Create a file called

~/.curlrc

In it insert one line

-k

Then try again.

(Warning: This answer disables curl's CA verification. "-k" is shorthand for "--insecure". Don't copy it blindly. -edit)

5
  • 1
    Works like a magic!
    – K. Symbol
    Apr 19, 2022 at 13:54
  • 4
    you should add the meaning this option
    – fuat
    May 9, 2022 at 9:22
  • 2
    From man curl: -k, --insecure (TLS) By default, every SSL connection curl makes is verified to be secure. This option allows curl to proceed and operate even for server connections otherwise considered insecure. The server connection is verified by making sure the server's certificate contains the right name and ver‐ ifies successfully using the cert store. See this online resource for further details: curl.haxx.se/docs/sslcerts.html May 16, 2022 at 16:29
  • echo "-k" > ~/.curlrc
    – cmcculloh
    Oct 7, 2022 at 17:03
  • This makes your curl less secure, BE CAREFUL! (fixing it is easy, just look at my answer: stackoverflow.com/a/36300754/1439843) Oct 8, 2022 at 19:00
36

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
    
3
  • 5
    This is the right answer. I did the first one initially and the problem returned.
    – GenericJam
    Oct 20, 2016 at 17:29
  • May also depend on your flavor of Linux, on my RHEL7 I had to instead use "export CURL_CA_BUNDLE=/etc/pki/tls/certs/ca-bundle.crt"
    – Eric Soyke
    Sep 30, 2020 at 19:43
  • @EricSoyke thanks, updated the answer with RHEL bundle location Oct 12, 2020 at 9:33
11

Changing from

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

To

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

Worked for me :)

1
  • 1
    This fixed it for me Nov 24, 2021 at 6:14
10

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
3
  • 1
    This didn't do anything for me (didn't work), but seems to point the right direction of the issue (Expired certificates), so give it a try Apr 15, 2021 at 14:56
  • That fixed all for me. Jun 6, 2021 at 3:12
  • I added the --fresh option (as recommended via another site). Then nvm ls-remote worked for me.
    – tdrury
    Oct 11, 2022 at 15:26
9

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.

1
  • to check this quickly cat nvm.sh | grep "curl.*nodejs.org/dist" , and check the results
    – bvdb
    Jun 27, 2021 at 14:45
9

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
1
  • I am using a ubuntu docker image and only this worked for me Dec 13, 2021 at 10:54
4

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.

3

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"
2

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

1
  • The end / after dist did the trick. Thanks. Just for additional info, rather than editing the nvm.sh, you can just add export NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist/ to one of the following files ~/.bashrc, ~/.zshrc, ~/.profile Dec 6, 2021 at 10:31
1

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.

1

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.

0
0

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

0

For me, this will work

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

1
  • wait ... do I need node before I can install nvm ?
    – bvdb
    Jun 27, 2021 at 14:47
0

It's work for me in my linux:

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

0

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.

0

For nvm-windows use nvm list available

0

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.

0

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!

0

I was facing similar issue in ubuntu and I found that the issue is not related NVM but it's not able to reach to node repository due to Proxy setting so I did the below steps and then it worked as expected

  • open /etc/apt/apt.conf

    nano  /etc/apt/apt.conf

  • Add the following to the above opened file

Acquire::http::proxy "http://<proxy-user>:<proxy-pass>@<proxy-url>:<proxy-port>" Acquire::https::proxy "http://<proxy-user>:<proxy-pass>@<proxy-url>:<proxy-port>" 

  • run below command

    export http_proxy='http://<proxy-user>:<proxy-pass>@<proxy-url>:<proxy-port>'

    export https_proxy='http://<proxy-user>:<proxy-pass>@<proxy-url>:<proxy-port>'

then your proxy issue will resolve and gives list of node version

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.