NVM 无法在 ubuntu 18.04 上安装 nodejs

NVM can not install nodejs on ubuntu 18.04

我尝试在 ubuntu 18.04 上使用 nvm 安装 nodejs。但每次它抛出以下错误堆栈

pasindu@pasindu-HP-EliteBook-850-G7-Notebook-PC:~$ nvm install 0.10.35

Downloading and installing node v0.10.35...
Downloading https://nodejs.org/dist/v0.10.35/node-v0.10.35-linux-x64.tar.gz...
Warning: Failed to create the file                                             
Warning: /home/pasindu/.nvm/.cache/bin/node-v0.10.35-linux-x64/node-v0.10.35-li
Warning: nux-x64.tar.gz: Permission denied
curl: (23) Failure writing output to destination

Binary download from https://nodejs.org/dist/v0.10.35/node-v0.10.35-linux-x64.tar.gz failed, trying source.
grep: /home/pasindu/.nvm/.cache/bin/node-v0.10.35-linux-x64/node-v0.10.35-linux-x64.tar.gz: No such file or directory
Provided file to checksum does not exist.
Binary download failed, trying source.
Detected that you have 12 CPU core(s)
Running with 11 threads to speed up the build
Downloading https://nodejs.org/dist/v0.10.35/node-v0.10.35.tar.gz...
Warning: Failed to create the file                                             
Warning: /home/pasindu/.nvm/.cache/src/node-v0.10.35/node-v0.10.35.tar.gz: 
Warning: Permission denied
curl: (23) Failure writing output to destination

Binary download from https://nodejs.org/dist/v0.10.35/node-v0.10.35.tar.gz failed, trying source.
grep: /home/pasindu/.nvm/.cache/src/node-v0.10.35/node-v0.10.35.tar.gz: No such file or directory
Provided file to checksum does not exist.

可能是snap curl的问题,见here,因为我一开始用snap安装curl,总是遇到这个问题,后来用sudo snap remove curl去掉curl,用sudo apt install curl,我目前的 curl 版本是 7.68.0。然后解决了。

我必须清除缓存: nvm cache clear.

我尝试安装我已经尝试安装的 Node 版本后出现错误,但是由于断开与 Internet 的连接,安装过程在第一次失败。