Ubuntu 24.04 中 nvm 安装 Node 权限问题解决
个人博客地址:Ubuntu 24.04 中 nvm 安装 Node 权限问题解决 | 一张假钞的真实世界
参考nvm的一个issue:https://github.com/nvm-sh/nvm/issues/3363
异常信息如下:
$ nvm install 22
Downloading and installing node v22.19.0...
Downloading https://nodejs.org/dist/v22.19.0/node-v22.19.0-linux-x64.tar.xz...
-#O=# # # Warning: Failed to open the file /home/zhangjc/.nvm/.cache/bin/node-v22.19.0-linux-x64/node-v22.19.0-linux-x64.tar.xz: Permission denied
curl: (23) client returned ERROR on write of 1360 bytesdownload from https://nodejs.org/dist/v22.19.0/node-v22.19.0-linux-x64.tar.xz failed
grep: /home/zhangjc/.nvm/.cache/bin/node-v22.19.0-linux-x64/node-v22.19.0-linux-x64.tar.xz: 没有那个文件或目录
Provided file to checksum does not exist.
Binary download failed, trying source.
Downloading https://nodejs.org/dist/v22.19.0/node-v22.19.0.tar.xz...
-=#=- # # # Warning: Failed to open the file /home/zhangjc/.nvm/.cache/src/node-v22.19.0/node-v22.19.0.tar.xz: Permission denied
curl: (23) client returned ERROR on write of 1360 bytesdownload from https://nodejs.org/dist/v22.19.0/node-v22.19.0.tar.xz failed
grep: /home/zhangjc/.nvm/.cache/src/node-v22.19.0/node-v22.19.0.tar.xz: 没有那个文件或目录
Provided file to checksum does not exist.
卸载使用 snap 安装的 curl:
$ sudo snap remove curl --purge
重新安装 curl:
$ sudo apt install curl
再次安装 node 成功:
$ nvm install 22
Downloading and installing node v22.19.0...
Downloading https://nodejs.org/dist/v22.19.0/node-v22.19.0-linux-x64.tar.xz...
################################################################################################################################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v22.19.0 (npm v10.9.3)
Creating default alias: default -> 22 (-> v22.19.0)