73

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.

11 Answers 11

160

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.

3
  • 1
    this solved my problem as well as i have mentioned in a separate answer
    – N Jedidiah
    Commented Sep 8, 2021 at 20:28
  • i hate computers so much
    – MarcGuay
    Commented Feb 19 at 20:00
  • Thanks, this solved the issue. And yes! Indeed things like these are reasons to hate computers. :-)
    – Bernd
    Commented Aug 20 at 14:05
130

uninstall curl installed with snap

sudo snap remove curl

install curl from apt

sudo apt install curl
13

I had the same issue (having previously installed curl with snap). After UNinstalling curl nvm worked as expected.

$ sudo snap remove curl
2
  • 3
    JFYI.. Dont forget to restart terminal after removing curl Commented Sep 18, 2021 at 5:51
  • 1
    In my case I just uninstalled curl from snap and installed through apt, in sequence, without restarting terminal I could repeat nvm install --lts and it worked as a charm. Commented Nov 16, 2022 at 0:45
11

This worked

In simple words i did this and it worked...

>snap list
>sudo snap remove curl

This will delete curl that was installed through snap. We need to install using apt

>sudo apt-get install curl

Now we need to install nvm using curl

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

Now simply install the node version u want.

>nvm install v14.17.0

In order to list all nvm version simply do so.

>nvm ls

And in order to switch just type the following command.

>nvm use v12.X.XX
9

I had the same issue. It was due to the lack of "libssl-dev". Run the following command before you start the installation process for nvm

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

1
  • Reinstalling the curl fixed my issue. Thank you. Commented Jun 3, 2021 at 20:09
3

I have had the exact same issue today as well, I'm not sure if its been an issue with NVM or if its just my Linux install being screwy but I have managed to get around it for the moment by manually downloading the tar file for the node version you want to install, move it to nvm's cache and then running nvm install again. I'll leave exact steps below and I'll try and remember to come back and update this Q if I work out why curl doesnt want to create a file in the .nvm dir

I have tried everything I can think of to try allow curl to save to the nvm directory, installing nvm using sudo, chown the dir, add full rwx permissions for user group and other for the dir, manually install nvm, nothing had worked for me so at present my best solution is below :)

Work around fix (using v16.1.0 of node as the example):

1 - run the curl command to download the version of node you want into your home directory

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 - copy the file to the nvm cache

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 - run nvm install again

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

It says Permission denied, try the same command with sudo

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

2

You can try creating folder and giving write permission to it:

  1. Create folder mkdir ~/.nvm

  2. Give permission for example: sudo chmod 777 ~/.nvm

Note :In my case, I passed these steps, but I got another permission error during installation of a node version with nvm, and solved it by using this command: sudo chmod 777 /private/tmp

1
  • I already had the folder, but for some reason write permissions were denied. Running sudo chmod 777 ~/.nvm fixed it. Commented Feb 12 at 15:07
0

check your NVM_DIR environment variable, mine was set incorrectly after transferred from an older machine

0

I am on a Windows machine (Windows 10) and I use Git Bash (I realize this is not supported -- see below).

I got a Permissions denied error on trying to nvm install --lts

The Permissions denied was related to this folder:

C:\Users\{my_user}\AppData\Local\Microsoft\WindowsApps\python3

I don't know what was wrong with that file/folder; python3.exe and etc were all 0 bytes. So I deleted the WindowsApps , and I got past this Permission denied error

BE CAREFUL, not sure this is appropriate for you, I only did it on the assumption that \AppData\Local is cached data -- which can be deleted without problems


After getting past the Permissions denied error, but I got a new error like Did not find a new enough assembler

I was able to fix this assembler related error by running the command: cd "$NVM_DIR" && git checkout master as described here

-1

For me the problem was different, and the solution was to create an SSH Key for GitHub and add it in my profile.

See related documentation here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.