I recently moved all my developer work (that is supported) to Windows Subsystem for Linux v2, on an Ubuntu 20.04. The increased speed of Node.js and npm is a blessing for my developing work as opposed to running them on Windows. Recently I needed to make a change to the theme of my blog, and it uses Yarn v1 as a package manager. I went on to install it, following the guide for Ubuntu.

The installation instructions were easy but when running yarn install, I got greeted with:

ERROR: [Errno 2] No such file or directory: 'install'

Digging in a bit deeper, it seems like there is already a yarn command installed in Ubuntu coming from the cmdtest package.

The installation instructions do point this out, only they point to a different error: issues executing the sudo apt install yarn command, but this worked without problems for me. Thus I didn't follow their guidance, and had to figure it out myself 😓

We need to remove the wrong package first, and then execute the steps from Yarn:

sudo apt remove cmdtest
sudo apt remove yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

If you want Yarn to install Node.js too, use the following command:

sudo apt update && sudo apt install yarn

If you have Node.js already, through nvm for example, use the following command:

sudo apt update && sudo apt install --no-install-recommends yarn

You can execute the versioning command to see if it all worked out:

yarn --version