I updated yarn from 1.22.22 to 4.1.1 with:
corepack enable
corepack prepare [email protected] --activate
yarn -v gives 4.1.1