Nvm ls-remote结果为N/A的解决方案

2019-12-22  本文已影响0人  zeroAzrael

事情是这样的:
我下了nvm,且在环境变量里添加了。
输入nvm install node时却出现了错误

 ~> nvm install node
Version 'node' not found - try `nvm ls-remote` to browse available versions.

尝试nvm ls-remote出现N/A


解决方案

1.临时请使用导出用于抓取内容的镜像的非https版本:exportNVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist
2.长久解决方案:
第一种:若您运行curl $NVM\_NODEJS\_ORG_MIRROR
出现

curl: (77) error setting certificate verify locations:
  CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none

则考虑修改~/.nvm/nvm.sh
在函数nvm_download()里修改,加上curl -k $*

 if nvm_has "curl"; then
    curl -k $*  #新加的
  elif nvm_has "wget"; then
    # Emulate curl with wget
...
}

第二种:若您您或第一种没用,考虑和我一样粗暴解法,直接将if语句种的crulwget换位置,如下(也就是先考虑wget了)

nvm_download() {
  local CURL_COMPRESSED_FLAG
  if nvm_has "wget"; then
        # Emulate curl with wget
    ARGS=$(nvm_echo "$@" | command sed -e 's/--progress-bar /--progress=bar /' \
                            -e 's/--compressed //' \
                            -e 's/--fail //' \
                            -e 's/-L //' \
                            -e 's/-I /--server-response /' \
                            -e 's/-s /-q /' \
                            -e 's/-sS /-nv /' \
                            -e 's/-o /-O /' \
                            -e 's/-C - /-c /')
    # shellcheck disable=SC2086
    eval wget $ARGS
  elif nvm_has "curl"; then
    if nvm_curl_use_compression; then
      CURL_COMPRESSED_FLAG="--compressed"
    fi
    curl --fail ${CURL_COMPRESSED_FLAG:-} -q "$@"
  fi
}

至此,问题解决。


参考:node.js - nvm ls-remote command results in "N/A" - Stack Overflow

上一篇 下一篇

猜你喜欢

热点阅读