尝试在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
但是,如果我编写了一个无法下载的脚本,它就会起作用:
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
想法?
看起来这与在Ubuntu:上安装wget或带有snap的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
卸载snap-ccurl并安装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