添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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.

This is most likely a problem with curl and not with nvm, please see my answer below ( stackoverflow.com/a/36300754/1439843 ) to fix curl. Gerhard Burger Mar 30, 2016 at 5:55

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.

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 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 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 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 @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 9, 2016 at 14:58 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 – Kyle Challis May 16, 2022 at 16:29 This makes your curl less secure, BE CAREFUL! (fixing it is easy, just look at my answer: stackoverflow.com/a/36300754/1439843) – Gerhard Burger Oct 8, 2022 at 19:00

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

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

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

    Worked for me :)

    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
                    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
    – Alexander Santos
                    Apr 15, 2021 at 14:56
                    I added the --fresh option (as recommended via another site). Then nvm ls-remote worked for me.
    – tdrury
                    Oct 11, 2022 at 15:26
    

    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

    http://nodejs.org/dist/

    makes it work.

    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
    

    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.

    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"

    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

    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 6, 2021 at 10:31

    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.

    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.

    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!

    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.

    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

    0.0.0.0 localhost

    Hope this helps anyone with the same issue. Thanks@ Truong Nguyen

    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.

    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

    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~

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.

  •