事情是這樣的:
我下了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