Ubuntu系统使用nvm安装Node.js v10.22.0遇权限拒绝错误求助
Node.js旧版本安装权限问题解决
问题描述
Ubuntu系统已安装Node.js v12.22.9,执行nvm install v10.22.0安装旧版本时,反复出现权限拒绝错误,具体错误信息如下:
Downloading and installing node v10.22.0... Downloading https://nodejs.org/dist/v10.22.0/node-v10.22.0-linux-x64.tar.xz... Warning: Failed to open the file Warning: /home/wand/.nvm/.cache/bin/node-v10.22.0-linux-x64/node-v10.22.0-linux Warning: -x64.tar.xz: Permission denied curl: (23) Failure writing output to destination Binary download from https://nodejs.org/dist/v10.22.0/node-v10.22.0-linux-x64.tar.xz failed, trying source. grep: /home/wand/.nvm/.cache/bin/node-v10.22.0-linux-x64/node-v10.22.0-linux-x64.tar.xz: 文件或目录不存在 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/v10.22.0/node-v10.22.0.tar.xz... Warning: Failed to open the file Warning: /home/wand/.nvm/.cache/src/node-v10.22.0/node-v10.22.0.tar.xz: Warning: Permission denied 0.0%curl: (23) Failure writing output to destination Binary download from https://nodejs.org/dist/v10.22.0/node-v10.22.0.tar.xz failed, trying source. grep: /home/wand/.nvm/.cache/src/node-v10.22.0/node-v10.22.0.tar.xz: 文件或目录不存在 Provided file to checksum does not exist.
解决方法
修复nvm缓存目录权限
错误核心是当前用户对/home/wand/.nvm/.cache目录没有写入权限,执行以下命令修改目录所有者:sudo chown -R $USER:$USER /home/wand/.nvm/.cache执行完后重新运行
nvm install v10.22.0即可。清理缓存后重试
如果权限修复后仍有问题,先清空nvm缓存再安装:nvm cache clear nvm install v10.22.0手动下载安装(备选方案)
若上述方法无效,手动下载安装包后指定路径安装:- 下载
node-v10.22.0-linux-x64.tar.xz到本地(比如~/Downloads目录) - 执行命令指定本地文件安装:
nvm install v10.22.0 --node-dir ~/Downloads
- 下载
内容的提问来源于stack exchange,提问作者Wanderson Silva
相关产品推荐
相关产品推荐

