Yarn のインストール(MacOS Catalina)

MacOS Catalina でやります。

$ brew install yarn

homebrewでインストールしてみると

The following directories are not writable by your user:
/usr/local/share/man/man3
/usr/local/share/man/man5
/usr/local/share/man/man7

You should change the ownership of these directories to your user.
  sudo chown -R $(whoami) /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7

And make sure that your user has write permission.
  chmod u+w /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7

と権限エラーがでるのでパーミッション変更してあげる

$ sudo chown -R $(whoami) /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7
$ chmod u+w /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7

もう一度

$ brew install yarn

とするとインストールは済むがエラーが出る

Error: An exception occurred within a child process:
  CompilerSelectionError: yarn cannot be built with any available compilers.
Install GNU's GCC:
  brew install gcc

gcc というのをインストールしてねと出るので

brew install gcc

をすると

$ yarn -v
1.22.5

と出るのでインストール完了