Install issue "sudo: yarn: command not found"

I am trying to install Peertube on my Debian 11 VM and am running into an error.
I have yarn installed. When I run « yarn -v » I get the output « 1.22.22 »
I have nodejs installed. When I run « node -v » I get « v18.20.2 »
I have created the user « peertube » and made sure it has sudo permissions

The trouble I am getting is when I get to the install step from the documentation.
I run
« cd ./peertube-latest && sudo -H -u peertube yarn install --production --pure-lockfile »

And get this error « sudo: yarn: command not found »

I am not sure where to go from here as I clearly have yarn installed. Any help would be appreciated.

You don’t have to add sudo permissions to the peertube user (and you should not for security reasons!)

This command suppose that your current bash user has sudo user. The sudo -u peertube tells to behave as the peertube user.

You can try sudo -H -u peertube which yarn, to check if yarn is found when running as the Peertube user.
If not, you should check how you created the peertube user. He probably has a wrong $PATH variable.

I was able to get the installer to run by modifying the command to point to the yarn and node paths.
cd ./peertube-latest && sudo -H -u peertube /var/www/peertube/.nvm/versions/node/v18.20.2/bin/node /var/www/peertube/.nvm/versions/node/v18.20.2/bin/yarn install --production --pure-lockfile

I then created a symbolic link from /usr/bin/node to the actual location of the node executable /var/www/peertube/.nvm/versions/node/v18.20.2/bin/node and a symbolic link from /usr/bin/yarn to the location of the yarn executable /var/www/peertube/.nvm/versions/node/v18.20.2/bin/yarn

My instance is up and running.


We don’t recommend to install nodejs using nvm (that causes this kind of issue). Please use the dependencies instructions instead: Dependencies | PeerTube documentation

The dependency instructions seem to direct the user to install node via nvm. Not sure how else to interpret the instructions on this page which the documentation links to.

Arf, NodeJS websites changed its URLs and redirects by default to the NVM installation :rage:

You can find the appropriate page on Node.js — Installing Node.js via package manager and can use GitHub - nodesource/distributions: NodeSource Node.js Binary Distributions