macOS上でyarnを入れる方法として公式ページにはHomeBrewで入れることを推奨しています。
上記のページに
nvm もしくは同様のものを使用している場合は、nvm のバージョンの Node.js を使用するように Node.js を除外してください。
と書かれていますが、nodebrewを使っている場合は以下のエラーメッセージが出てインストールできません。
$ brew install yarn --ignore-dependencies Warning: --ignore-dependencies is an unsupported Homebrew developer flag! Adjust your PATH to put any preferred versions of applications earlier in the PATH rather than using this unsupported flag! ==> Downloading https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz Already downloaded: /Users/miyohide/Library/Caches/Homebrew/downloads/42f75ed3036d8636bc54f4cf04cd43310a9662428287c2f0187e82ebedf82c95--yarn-v1.22.4.tar.gz Error: An exception occurred within a child process: RuntimeError: /usr/local/opt/node not present or broken Please reinstall node. Sorry :( $
これを解決するには、/usr/local/opt/node/
に~/.nodebrew/current/
へのシンボリックリンクを張り、再度インストールを試みるとOKです。
$ mkdir /usr/local/opt/node $ ln -s ~/.nodebrew/current/ /usr/local/opt/node/ $ brew install yarn --ignore-dependencies Updating Homebrew... ==> Auto-updated Homebrew! Updated 1 tap (homebrew/core). No changes to formulae. Warning: --ignore-dependencies is an unsupported Homebrew developer flag! Adjust your PATH to put any preferred versions of applications earlier in the PATH rather than using this unsupported flag! ==> Downloading https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz Already downloaded: /Users/miyohide/Library/Caches/Homebrew/downloads/42f75ed3036d8636bc54f4cf04cd43310a9662428287c2f0187e82ebedf82c95--yarn-v1.22.4.tar.gz 🍺 /usr/local/Cellar/yarn/1.22.4: 14 files, 5MB, built in 1 second $
動作確認としてバージョン番号を表示させます。
$ yarn -v 1.22.4 $