Sep 15, 2020 1 min read

Get Yarn v1 to work in Ubuntu 20.04 on Windows Subsystem for Linux v2

Get the Yarn package manager installed on Ubuntu 20.04 running on Windows Subsystem for Linux v2

Get Yarn v1 to work in Ubuntu 20.04 on Windows Subsystem for Linux v2

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
Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Yannick Reekmans.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.