You can solve this by using following steps:
First remove yarn globally
npm uninstall -g yarn
Open the terminal or command line in your project and run
corepack enable
Then finally run yarn set version 3.6.4. Corepack willl now use yarn version 3.6.4 in your project.