Ubuntu上nvm和最新版本nodejs(加速)安装

玖亖伍
2022-08-13 / 0 评论 / 893 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2022年08月13日,已超过830天没有更新,若内容或图片失效,请留言反馈。

操作

-- 下载nvm安装脚本
wget -c -O nvm-install.sh https://ghproxy.com/https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh
-- 将nvm-install.sh中的下载链接前添加 https://ghproxy/
安装nvm
bash nvm-install.sh
# 重新加载 ~/.bashrc, 使nvm命令可用
source ~/.bashrc
# 设置nodejs国内源
export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node/
# 安装nodejs
nvm install --lts

nvm-install.sh修改Diff

@@ -59,14 +59,14 @@ nvm_source() {
   local NVM_SOURCE_URL
   NVM_SOURCE_URL="$NVM_SOURCE"
   if [ "_$NVM_METHOD" = "_script-nvm-exec" ]; then
-    NVM_SOURCE_URL="https://raw.githubusercontent.com/${NVM_GITHUB_REPO}/${NVM_VERSION}/nvm-exec"
+    NVM_SOURCE_URL="https://ghproxy.com/https://raw.githubusercontent.com/${NVM_GITHUB_REPO}/${NVM_VERSION}/nvm-exec"
   elif [ "_$NVM_METHOD" = "_script-nvm-bash-completion" ]; then
-    NVM_SOURCE_URL="https://raw.githubusercontent.com/${NVM_GITHUB_REPO}/${NVM_VERSION}/bash_completion"
+    NVM_SOURCE_URL="https://ghproxy.com/https://raw.githubusercontent.com/${NVM_GITHUB_REPO}/${NVM_VERSION}/bash_completion"
   elif [ -z "$NVM_SOURCE_URL" ]; then
     if [ "_$NVM_METHOD" = "_script" ]; then
-      NVM_SOURCE_URL="https://raw.githubusercontent.com/${NVM_GITHUB_REPO}/${NVM_VERSION}/nvm.sh"
+      NVM_SOURCE_URL="https://ghproxy.com/https://raw.githubusercontent.com/${NVM_GITHUB_REPO}/${NVM_VERSION}/nvm.sh"
     elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; then
-      NVM_SOURCE_URL="https://github.com/${NVM_GITHUB_REPO}.git"
+      NVM_SOURCE_URL="https://ghproxy.com/https://github.com/${NVM_GITHUB_REPO}.git"
     else
       nvm_echo >&2 "Unexpected value \"$NVM_METHOD\" for \$NVM_METHOD"
       return 1
0

评论 (0)

取消