我正在尝试安装稳定版本的节点,现在为 16.x。Ubuntu 的存储库为 10.19。我尝试使用nvm
并得到以下结果:
@nspiron-N5010:~$ nvm install 16.10.0
Downloading and installing node v16.10.0...
Downloading https://nodejs.org/dist/v16.10.0/node-v16.10.0-linux-x64.tar.xz...
Warning: Failed to create the file
Warning: /home/***/.nvm/.cache/bin/node-v16.10.0-linux-x64/node-v16.10.0-linux-
Warning: x64.tar.xz: Permission denied
0.0%curl: (23) Failure writing output to destination
Binary download from https://nodejs.org/dist/v16.10.0/node-v16.10.0-linux-x64.tar.xz failed, trying source.
grep: /home/***/.nvm/.cache/bin/node-v16.10.0-linux-x64/node-v16.10.0-linux-x64.tar.xz: No such file or directory
Provided file to checksum does not exist.
Binary download failed, trying source.
Detected that you have 4 CPU core(s)
Running with 3 threads to speed up the build
Downloading https://nodejs.org/dist/v16.10.0/node-v16.10.0.tar.xz...
Warning: Failed to create the file
Warning: /home/***/.nvm/.cache/src/node-v16.10.0/node-v16.10.0.tar.xz:
Warning: Permission denied
0.0%curl: (23) Failure writing output to destination
Binary download from https://nodejs.org/dist/v16.10.0/node-v16.10.0.tar.xz failed, trying source.
grep: /home/***/.nvm/.cache/src/node-v16.10.0/node-v16.10.0.tar.xz: No such file or directory
Provided file to checksum does not exist.
我做错了什么?
答案1
我尝试了这里的所有建议,但都没有用。我尝试重新启动,甚至下载该文件并将其放在 nvm 缓存箱中。直到……都没有成功。
简单的解决方案:
如果您已经curl
通过使用安装snap
,则请先卸载它:
sudo snap remove curl
然后使用以下命令重新安装apt
:
sudo apt install curl
现在你可以使用以下命令安装节点:
npm install 18
(目前为v18,请替换18
为您需要的版本)
答案2
以防有人感到疑惑:nodejs 已经更新,但需要重启 ubuntu而是像教程要求的那样关闭和打开终端。未重启的系统一直显示旧版本的节点,而新版本已经安装,另一个安装过程搞乱了 ubuntu。所以我的建议是重启 ubuntu,而不仅仅是关闭和打开终端。