Search code examples
node.jslinuxnvm

NVM: Getting Permission denied with nvm install command


I recently fresh-installed Ubuntu 21.04 and wanted to install nvm:

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

Then closed and re-opened the terminal. When requesting an install of version 12.16.3 (have tried with other versions as well). I'm getting the following error:

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.

Solution

  • Posted an issue to nvm's repo

    Turns out the problem was with curl and that I had installed it with snap instead of regular apt install curl.