Recently I faced this same issue.
I highly recommend you use the LTS(long term support) version of the node.
You can validate the version here: https://nodejs.org/en
when I’m writing this answer the node LTS version is 20.10.0
so then in your command line you should perform:
$nvm install 20.10.0
$nvm use 20.10.0
This solves the problem, because makes you use the most tested and approved version.
If I use the version with latest features (actually 21.5.0) I will face the problem reported here. There is an issue open in github to solve it by the way.
You can see more details here: https://github.com/yarnpkg/yarn/issues/9005