事情是这样的:
我下了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
语句种的crul
和wget
换位置,如下(也就是先考虑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
网友评论