在 Ubuntu 20.04 LTS 上安装 NVM?

Ole*_*Ole 4 linux bash ubuntu node.js nvm

尝试在 Ubuntu 20.04 LTS 上安装 NVM。当我运行安装脚本时,会发生这种情况:

\n
\nole@ole-ThinkPad-T470:~/Temp/nv$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash\n=> Downloading nvm as script to '/home/ole/.nvm'\nFailed to download 'https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/nvm-exec'\nFailed to download 'https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/nvm.sh'\n\n=> nvm source string already in /home/ole/.bashrc\nFailed to download 'https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/bash_completion'\n=> bash_completion source string already in /home/ole/.bashrc\nmain: line 433: /home/ole/.nvm/nvm.sh: No such file or directory\n=> Close and reopen your terminal to start using nvm or run the following to use it now:\n\nexport NVM_DIR="$HOME/.nvm"\n[ -s "$NVM_DIR/nvm.sh" ] && \\. "$NVM_DIR/nvm.sh"  # This loads nvm\n[ -s "$NVM_DIR/bash_completion" ] && \\. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion\n
Run Code Online (Sandbox Code Playgroud)\n

但是,如果我 wget 无法下载的脚本之一,它就会起作用:

\n
\nole@ole-ThinkPad-T470:~/Temp/nv$ wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/nvm-exec\n--2021-05-25 18:39:08--  https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/nvm-exec\nResolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.133, 185.199.108.133, 185.199.111.133, ...\nConnecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|:443... connected.\nHTTP request sent, awaiting response... 200 OK\nLength: 344 [text/plain]\nSaving to: \xe2\x80\x98nvm-exec.1\xe2\x80\x99\n\nnvm-exec.1                       100%[========================================================>]     344  --.-KB/s    in 0s      \n\n2021-05-25 18:39:08 (4.25 MB/s) - \xe2\x80\x98nvm-exec.1\xe2\x80\x99 saved [344/344]\n\nole@ole-ThinkPad-T470:~/Temp/nv$ ls\nnvm-exec\n\n
Run Code Online (Sandbox Code Playgroud)\n

想法?

\n

Ole*_*Ole 8

看起来它与在Ubuntu上安装wget或curl with snap有关:

https://github.com/nvm-sh/nvm/issues/2504

这是为我解决的问题:

sudo snap remove curl
sudo apt install curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
nvm install node
Run Code Online (Sandbox Code Playgroud)