90

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.

eComEvo
  • 11,669
  • 26
  • 89
  • 145
  • 2
    Looks like maybe this issue got fixed? https://github.com/creationix/nvm/issues/554 – B T Oct 05 '15 at 23:01
  • 2
    This is most likely a problem with curl and not with nvm, please see my answer below (http://stackoverflow.com/a/36300754/1439843) to fix curl. – Gerhard Burger Mar 30 '16 at 05:55

22 Answers22

112

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.

Jeffrey Martinez
  • 4,384
  • 2
  • 31
  • 36
  • Right now I am on a vagrant box (laravel/homestead) on Mac OS 10.9. The box it fresh, so there shouldn't be anything nasty. Funny thing is, this is the same edition of the box I have on Windows PC and it works just fine. – eComEvo Oct 21 '14 at 01:30
  • It wouldn't be your box, it's on the mirror's end, I don't think there's much we can do to fix the root of the issue on our end. See my easier suggestion in the edit. Good luck! – Jeffrey Martinez Oct 21 '14 at 01:31
  • 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 '14 at 01: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 '14 at 01:59
  • I have `curl -q` and replace witth `-k` solution worked! The export didnt work also. Thanks! – Spurdow Mar 07 '16 at 13:54
  • I met the same symptom on Kubuntu 16.04. The problem was that curl expected `/etc/pki/tls/certs/ca-bundle.crt`, while in 16.04 it is in different place and is called differently: `/etc/ssl/certs/ca-certificates.crt`. Linking file to the position where curl expects it solved the issue: `sudo mkdir -p /etc/pki/tls/certs/ && sudo ln -s /etc/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-bundle.crt`. – Adobe Jun 05 '16 at 11:18
  • 9
    I'm the http://nvm.sh maintainer. Please DO NOT edit nvm.sh directly. If you have SSL issues, *fix your SSL issues*. – LJHarb Jun 07 '16 at 23:28
  • @LJHarb any ideas on what ssl issues users might be running into they can fix? As I recall (though this a while ago for me) I didn't change anything when I had this issue. `nvm ls-remote` just stopped working for a few hours, then went back to normal. Happy to update the answer with your input. – Jeffrey Martinez Jun 08 '16 at 05:25
  • 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 http://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 09 '16 at 05: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 :) – Jeffrey Martinez Jun 09 '16 at 14:58
  • Thanks, much obliged :-) I want to fix bugs for everyone, and make sure future nvm upgrades are seamless – LJHarb Jun 10 '16 at 20:29
  • 1
    In my case I am getting below response for `curl $NVM_NODEJS_ORG_MIRROR` `curl (7) Failed to connect to nodejs.org port 80: Network is unreachable` though I am able to `curl google.com` and able to open `http://nodejs.org/dist/` from browser – Rahul Shukla Nov 05 '16 at 15:36
  • 1
    The golden command line was for me `export NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist` – Adam Bubela Aug 10 '17 at 09:35
  • 1
    ```export NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist/``` worked for me the / was needed as the original link now redirects to the / one – xeo May 16 '18 at 16:39
  • Over a year I've had this problem... Thank you sir. PS> Didn't work for me until I put the -k command into nvm.sh – Carson the Powers Jan 28 '21 at 23:34
  • Doing this in Windows bash, and adding the `-k` flag to curl command in `nvm.sh` fixed the issue for me. Thanks. – Kon Nov 02 '21 at 15:11
  • pre-edit solution worked! – Isaac I9 Dec 06 '22 at 16:53
49

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)

Glenn Maynard
  • 55,829
  • 10
  • 121
  • 131
hawkeye
  • 34,745
  • 30
  • 150
  • 304
  • 2
    Works like a magic! – K. Symbol Apr 19 '22 at 13:54
  • 4
    you should add the meaning this option – fuat May 09 '22 at 09: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: https://curl.haxx.se/docs/sslcerts.html – Kyle Challis May 16 '22 at 16:29
  • 3
    `echo "-k" > ~/.curlrc` – cmcculloh Oct 07 '22 at 17:03
  • This makes your curl less secure, BE CAREFUL! (fixing it is easy, just look at my answer: https://stackoverflow.com/a/36300754/1439843) – Gerhard Burger Oct 08 '22 at 19:00
38

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
    
Gerhard Burger
  • 1,379
  • 1
  • 16
  • 25
13

Changing from

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

To

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

Worked for me :)

nhaht
  • 1,005
  • 12
  • 21
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
Chris L8
  • 111
  • 2
  • 6
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.

holdfenytolvaj
  • 5,637
  • 1
  • 17
  • 10
  • to check this quickly `cat nvm.sh | grep "curl.*nodejs.org/dist"` , and check the results – bvdb Jun 27 '21 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
Clairton Luz
  • 2,116
  • 19
  • 15
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.

Matt Olsen
  • 83
  • 5
4

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"
Mr. 14
  • 9,228
  • 6
  • 37
  • 54
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

Mohammad Abbas
  • 556
  • 1
  • 4
  • 11
  • 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` – James Antony Dec 06 '21 at 10:31
2

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.

Michael Stahl
  • 208
  • 3
  • 9
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.

Peter Paul
  • 384
  • 3
  • 13
1

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!

mczarnek
  • 1,305
  • 2
  • 11
  • 24
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.

Rm4n
  • 623
  • 7
  • 14
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

Community
  • 1
  • 1
seamonkey
  • 21
  • 2
0

For me, this will work

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

Anil Yadav
  • 1,086
  • 7
  • 18
0

It's work for me in my linux:

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

Damiana
  • 11
  • 2
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.

mberna
  • 313
  • 5
  • 18
0

For nvm-windows use nvm list available

trinaldi
  • 2,872
  • 2
  • 32
  • 37
Scirocco
  • 1,327
  • 10
  • 13
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

GUDDU KUMAR
  • 401
  • 4
  • 12
0

If you are using any proxy/VPN, disable it and try again

Said Erraoudy
  • 1,490
  • 1
  • 13
  • 21
0

Firstly, introduce my device and environment: macOS and shadowsocks proxy.

I take steps to fix it. nvm ls-remote command results in "N/A"

I try every method on the internet and i find one method is in effect for me.

vim ~/.curlrc and then add some sentences like:

proxy="http:<proxy-password>@<proxy-url>:<proxy-port>"
proxy="socks5:<proxy-password>@<proxy-url>:<proxy-port>"
// if you have username, you can do this
proxy="http:<proxy-username>:<proxy-password>@<proxy-url>:<proxy-port>"
// it's my example, you need find your url and port, here password is faked.
proxy="socks5://6Bn23U5ceOMS4g@127.0.0.1:1080"
proxy="http://6Bn23U5ceOMS4g@127.0.0.1:1081"

finally, source ~/.curlrc

congrats~