【问题标题】:NVM: Getting Permission denied with nvm install commandNVM:使用 nvm install 命令拒绝获取权限
【发布时间】:2021-05-14 21:57:33
【问题描述】:

我最近全新安装了 Ubuntu 21.04 并想安装 nvm:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

然后关闭并重新打开终端。请求安装版本12.16.3 时(也尝试过其他版本)。我收到以下错误:

nvm install 12.16.3
Downloading and installing node v12.16.3...
Downloading https://nodejs.org/dist/v12.16.3/node-v12.16.3-linux-x64.tar.xz...
Warning: Failed to create the file 
Warning: /home/sauronnikko/.nvm/.cache/bin/node-v12.16.3-linux-x64/node-v12.16.
Warning: 3-linux-x64.tar.xz: Permission denied
curl: (23) Failure writing output to destination

Binary download from https://nodejs.org/dist/v12.16.3/node-v12.16.3-linux-x64.tar.xz failed, trying source.
grep: /home/sauronnikko/.nvm/.cache/bin/node-v12.16.3-linux-x64/node-v12.16.3-linux-x64.tar.xz: No such file or directory
Provided file to checksum does not exist.
Binary download failed, trying source.
Downloading https://nodejs.org/dist/v12.16.3/node-v12.16.3.tar.xz...
Warning: Failed to create the file 
Warning: /home/sauronnikko/.nvm/.cache/src/node-v12.16.3/node-v12.16.3.tar.xz: 
Warning: Permission denied
curl: (23) Failure writing output to destination

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

【问题讨论】:

    标签: node.js linux nvm


    【解决方案1】:

    在 nvm 的仓库中发布了 issue

    原来问题出在curl 上,而我是用snap 而不是常规的apt install curl 安装的。

    【讨论】:

    • 这解决了我的问题以及我在单独的答案中提到的问题
    【解决方案2】:

    卸载curlsnap一起安装

    sudo snap remove curl
    

    apt 安装curl

    sudo apt install curl
    

    【讨论】:

      【解决方案3】:

      我有同样的问题。这是由于缺少“libssl-dev”。在开始 nvm 的安装过程之前运行以下命令

      sudo apt-get install build-essential libssl-dev curl git-core

      【讨论】:

      • 重新安装 curl 解决了我的问题。谢谢。
      【解决方案4】:

      我也遇到了同样的问题(之前使用 snap 安装了 curl)。卸载 curl nvm 后按预期工作。

      $ sudo snap remove curl
      

      【讨论】:

      • JFYI.. 删除 curl 后不要忘记重启终端
      【解决方案5】:

      上面写着Permission denied,用sudo试试同样的命令

      sudo curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

      【讨论】:

        【解决方案6】:

        我今天也遇到了完全相同的问题,我不确定是 NVM 的问题还是只是我的 Linux 安装出了问题,但我暂时通过手动下载解决了这个问题要安装的节点版本的 tar 文件,将其移动到 nvm 的缓存,然后再次运行 nvm install。我将在下面留下确切的步骤,如果我弄清楚为什么 curl 不想在 .nvm 目录中创建文件,我会尽量记住回来更新这个 Q

        我已经尝试了所有我能想到的尝试允许 curl 保存到 nvm 目录,使用 sudo 安装 nvm,chown 目录,为用户组和其他目录添加完整的 rwx 权限,手动安装 nvm,什么都没有为我工作,所以目前我最好的解决方案如下:)

        解决方法(以节点 v16.1.0 为例):

        1 - 运行 curl 命令将你想要的节点版本下载到你的主目录中

        curl https://nodejs.org/dist/v16.1.0/node-v16.1.0-linux-x64.tar.xz --output node-v16.1.0-linux-x64.tar.xz
        

        2 - 将文件复制到 nvm 缓存

        sudo mv node-v16.1.0-linux-x64.tar.xz ~/.nvm/.cache/bin/node-v16.1.0-linux-x64/node-v16.1.0-linux-x64.tar.xz
        

        3 - 再次运行 nvm install

        nvm install node (or whatever version you are trying to install)
        

        【讨论】:

          【解决方案7】:

          成功了

          简单来说,我做到了,它成功了......

          >snap list
          >sudo snap remove curl
          

          这将删除通过 snap 安装的 curl。 我们需要使用apt安装

          >sudo apt-get install curl
          

          现在我们需要使用 curl 安装 nvm

          >curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
          

          现在只需安装您想要的节点版本。

          >nvm install v14.17.0
          

          要列出所有 nvm 版本,只需这样做。

          >nvm ls
          

          要切换,只需键入以下命令。

          >nvm use v12.X.XX
          

          【讨论】:

            【解决方案8】:

            检查你的 NVM_DIR 环境变量,我的从旧机器转移后设置不正确

            【讨论】:

              猜你喜欢
              • 2017-09-29
              • 1970-01-01
              • 2018-07-23
              • 2020-10-06
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2021-11-02
              • 2023-01-26
              相关资源
              最近更新 更多