Getting the right yarn installed on Ubuntu. Where to see yarn used in Rails programming

I am setting up the latest Rails on a new laptop running the latest Ubuntu distribution. I have step by step setup notes from my desktop machine about a year old. I am still getting tripped up trying to install yarn with --version 1.22.0.
My first request is would somebody point me to some example of yarn being used in Rails? Or, stepping back a bit further, some example of yarn being used in javascript at the command line where I can see what it does? Finally, here is what I finally did to get the requested --version 1.22.0 installed on Ubuntu: First program here installs yarn --version 1.22.0 but it is located at /usr/local/bin/yarn sudo npm install --global yarn locate /bin/yarn ; see /usr/local/bin/yarn ln -s /usr/local/bin/yarn /usr/bin/yarn ; soft link use sudo

In the “Getting started” Rails Guide, find the section where you do " ``` rails new blog

Then you are instructed to change directory into the blog subdirectory.
Scroll down in the tutorial text and see comments about a file package.json
There it is... "This file allows you to specify what npm dependencies are needed for your Rails application. This file is used by Yarn. For more information about Yarn, see the [Yarn website](https://yarnpkg.com/lang/en/)."

Wait there is more! Open the file package.json and you will see the the file contents. Bingo! Yarn is a program to that manages dependencies by preventing the use of incompatible gems.