Stop installing yarn globally, use per-project yarn instead.
This allows migration per project.
Installing yarn by corepack enable is now the recommended way:
corepack enable
https://yarnpkg.com/migration/guide