在Ubuntu 20.04 LTS上安装NVM?

3
尝试在Ubuntu 20.04 LTS上安装NVM。运行安装脚本时出现以下情况:

ole@ole-ThinkPad-T470:~/Temp/nv$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
=> Downloading nvm as script to '/home/ole/.nvm'
Failed to download 'https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/nvm-exec'
Failed to download 'https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/nvm.sh'

=> nvm source string already in /home/ole/.bashrc
Failed to download 'https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/bash_completion'
=> bash_completion source string already in /home/ole/.bashrc
main: line 433: /home/ole/.nvm/nvm.sh: No such file or directory
=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

但是如果我使用wget下载其中一个失败的脚本,它就能正常工作:


ole@ole-ThinkPad-T470:~/Temp/nv$ wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/nvm-exec
--2021-05-25 18:39:08--  https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/nvm-exec
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.133, 185.199.108.133, 185.199.111.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 344 [text/plain]
Saving to: ‘nvm-exec.1’

nvm-exec.1                       100%[========================================================>]     344  --.-KB/s    in 0s      

2021-05-25 18:39:08 (4.25 MB/s) - ‘nvm-exec.1’ saved [344/344]

ole@ole-ThinkPad-T470:~/Temp/nv$ ls
nvm-exec

你的想法是什么?


1
你是否已安装了CURL? - cbr
@cbr,我起初也是这么想的,但是脚本确实包含使用wget的能力。 - Will Walsh
我尝试了curl和wget...结果相同。 - Ole
2个回答

7

看起来这与在Ubuntu上使用snap安装wget或curl有关:

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

完美的答案,谢谢 :) - Parth kharecha

1
卸载Snap Curl并安装apt install对我也解决了这个问题。
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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接