NVM:使用 nvm install 命令拒绝获取权限

sau*_*kko 4 linux node.js nvm

我最近全新安装了 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.
Run Code Online (Sandbox Code Playgroud)

NMu*_*ama 100

卸载curl安装了snap

sudo snap remove curl
Run Code Online (Sandbox Code Playgroud)

安装curlapt

sudo apt install curl
Run Code Online (Sandbox Code Playgroud)


sau*_*kko 21

向 nvm 的 repo发布了一个问题

事实证明问题出在curl我安装它snap而不是常规apt install curl.


小智 10

我遇到了同样的问题(之前已经安装了带有snap 的curl)。卸载curl nvm后按预期工作。

$ sudo snap remove curl
Run Code Online (Sandbox Code Playgroud)

  • JFYI..删除curl后不要忘记重新启动终端 (2认同)

小智 7

这有效

简而言之,我这样做了并且有效......

>snap list
>sudo snap remove curl
Run Code Online (Sandbox Code Playgroud)

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

>sudo apt-get install curl
Run Code Online (Sandbox Code Playgroud)

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

>curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
Run Code Online (Sandbox Code Playgroud)

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

>nvm install v14.17.0
Run Code Online (Sandbox Code Playgroud)

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

>nvm ls
Run Code Online (Sandbox Code Playgroud)

为了进行切换,只需输入以下命令。

>nvm use v12.X.XX
Run Code Online (Sandbox Code Playgroud)


小智 5

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

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