yarnのcacheでハマった


めったに起こらないエラーだと思うがyarnのキャッシュでハマった。同じ地雷を踏む人がいないとも限らないので書いておく。

ローカルで開発していたjavascriptのライブラリを

yarn add javascriptのライブラリのパス

でreactに追加して開発をしていたらyarn addの際に以下のエラーが出るようになった。

warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
error An unexpected error occurred: "ENOSPC: no space left on device, write".
info If you think this is a bug, please open a bug report with the information provided in "ライブラリのパス/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

no space left on deviceのエラーメッセージを検索するとメモリの問題だったりinodeの問題のケースもあるみたいだが、今回はディスク容量の問題で、いつの間にか何かが400GB以上、ディスク容量圧迫していて他の作業もまともに進まなくなった。

このmacについて→ストレージを開いて確認するも「その他」の領域のファイルが圧迫していることしかわからない(具体的なパスが出ない)

原因と解決

findとduコマンドで地道に調べていったところ以下のパスにyarnのcacheがたまっていた
$HOME/Library/Caches/Yarn/

開発していたライブラリのパスで
yarn cache clean
を実行して解決。