node.js nvm ls-remote 命令导致“不适用”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26476744/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 18:02:00  来源:igfitidea点击:

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

node.jsnvm

提问by eComEvo

I'm trying to install Node with nvm, but when I type any version it's not available. When I type nvm ls-remoteI just just get "N/A".

我正在尝试使用 nvm 安装 Node,但是当我输入任何版本时,它都不可用。当我输入时,nvm ls-remote我只是得到“N/A”。

I'm able to access the Internet, so I can't figure what could be going on.

我能够访问互联网,所以我无法弄清楚会发生什么。

回答by Jeffrey Martinez

Update with comment from LJHarb, who maintains nvm.sh

更新来自维护 nvm.sh 的 LJHarb 的评论

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.

LJHarb 建议导致此问题的典型问题是“您系统中安装的 SSL 证书颁发机构已过时”。检查并尝试解决此问题将是更好的第一步。

In the case where you believe there isa problem on the nvm.sh side, LJHarb asks that users file a bug on nvm.sh's issue tracker.

在你相信的情况在nvm.sh端的问题,LJHarb要求用户提交一个错误nvm.sh的问题跟踪器

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.

另外,我想指出,以下解决方案旨在作为解决方法,仅当您真的陷入困境时才临时使用。不建议永久修改导出的镜像或 nvm.sh 脚本本身。

Edit: Found easier fix

编辑:发现更容易修复

You can export the non https version of the mirror it uses to grab the stuff:

你可以导出它用来抓取东西的非 https 版本的镜像:

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

Then nvm works

然后 nvm 工作

Pre edit

预编辑

Had the same problem just now.

刚才有同样的问题。

Looks like by default it tries to use curl if it's available on your system.

看起来默认情况下它会尝试使用 curl 如果它在您的系统上可用。

I assume you're on linux also, so try running curl $NVM_NODEJS_ORG_MIRRORand see if you get the same error I did:

我假设您也在使用 linux,因此请尝试运行curl $NVM_NODEJS_ORG_MIRROR并查看是否遇到与我相同的错误:

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.shif you followed the install info), and you can add a -kon line 17 after the curl, so it looks like this:

也许某些证书已过期或以其他方式错误配置(或某人正在做一些令人讨厌的事情),直到它被修复,如果您不介意解决安全问题,您可以找到 nvm.sh 文件(~/.nvm/nvm.sh如果您遵循安装信息,则应该在),并且你可以-k在 curl 之后的第 17 行添加一个,所以它看起来像这样:

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

不要忘记重新启动 shell,然后尝试nvm ls-remote. 假设修复有效,您现在应该可以使用 nvm。

回答by Gerhard Burger

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 IMO much better to fix curl.

这很可能是由于 curl 无法为 https url 使用证书(使用 验证curl $NVM_NODEJS_ORG_MIRROR)造成的。不是使用 http url 作为解决方法,而是 IMO 更好地修复 curl。

Assuming you have the ca-certificatespackage installed, add the following line to your .bashrc(source1, source2):

假设你已经有ca-certificates安装包,下面一行添加到您的.bashrc源1源2):

export CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt

回答by holdfenytolvaj

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

网址末尾似乎缺少“/”,这就是 301 永久移动消息的原因。所以将 nvm.sh 中的链接从

http://nodejs.org/dist

http://nodejs.org/dist

to

http://nodejs.org/dist/

http://nodejs.org/dist/

makes it work.

使它工作。

回答by Clairton Luz

If you are using nvm behide a proxy you need set proxy config to curl

如果您在代理后面使用 nvm,则需要将代理配置设置为 curl

edit or create the file ~/.curlrcand add this line with your proxy

编辑或创建文件~/.curlrc并在您的代理中添加这一行

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

回答by Anil Yadav

For me, this will work

对我来说,这会奏效

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

nvm alias default node在最新安装的 Node 版本 (8.11.1) 上指向“默认”。

回答by Damiana

It's work for me in my linux:

它在我的 linux 中对我有用:

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

导出 NVM_NODEJS_ORG_MIRROR= http://nodejs.org/dist

回答by seamonkey

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 herethat 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 reloadI was able to run nvm ls-remoteand see a list of versions of node and install. Here is what I did on the vagrant box: cd /etc/

我在 Windows 7 上的 Virtual Box 4.3.30 下使用 Vagrant 1.7.1 运行 Ubuntu 14.04 盒子时遇到了这个问题。我尝试了上面的建议,但没有任何效果。我在这里找到了这篇文章,它与我在尝试运行时遇到的 Curl 错误有关:curl $NVM_NODEJS_ORG_MIRROR 错误是:curl: (7) Couldn't connect to server 我能够遵循该帖子上的建议,然后一旦我重新启动了我的 Vagrant 框,vagrant reload我就可以运行了nvm ls-remote并查看节点和安装版本的列表。这是我在 vagrant box 上所做的:cd /etc/

sudo nano hosts

changed 127.0.0.1 localhost

更改了 127.0.0.1 本地主机

to:

到:

0.0.0.0 localhost

0.0.0.0 本地主机

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

希望这可以帮助任何有同样问题的人。谢谢@ Truong Nguyen

回答by Matt Olsen

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-remoteworked just fine. Hope this helps save someone else some frustration.

我遇到了同样的问题,但其他解决方案都没有帮助。curl -v $NVM_NODEJS_ORG_MIRROR/显示了 TLS 1.2 并且证书没有问题。当我尝试时which curl,结果发现我的 PATH 中有一个 anaconda3/bin 目录,它有自己的 curl 版本(不知道他们为什么需要那个)。一旦我确定了我的路径,nvm ls-remote工作就很好。希望这有助于拯救别人一些挫折。