how to install yarn in ubuntu 18.04 code example

Example 1: install yarn

npm install -g yarn

Example 2: yarn download ubuntu

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
sudo apt update && sudo apt install yarn

Example 3: ubuntu install yarn

sudo apt install --no-install-recommends yarn

Example 4: problem installing yarn ubuntu

sudo apt remove cmdtest
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
sudo apt update
sudo apt install yarn

Example 5: install yarn

brew install yarn