LoginSignup
3
1

More than 3 years have passed since last update.

yarnでハマった話「Incorrect integrity when fetching from the cache」

Posted at

yarnを使ってパッケージをインストールした際にハマった

以下のようにパッケージをインストールした際にエラーが出ました。

yarn add gatsby-source-contentful

エラー文

yarn add v1.19.0
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
error Incorrect integrity when fetching from the cache
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

エラー文の意味

Incorrect integrity when fetching from the cache

単純に日本語訳してあげると
キャッシュからフィッチしてきて際に、整合性が取れてないよ
という意味らしい。

グローバルにインストールしたyarnを使う際に、プロダクト内のnpmとのcacheとバッティングしているのが原因なようです。

解決法

yarnのキャッシュを削除してあげましょう。

yarn cache clean

ちなみにcacheは以下のコマンドで確認できます。

yarn cache dir

プロダクト内でyarnを再インストールします。以下のようなコマンドでインストールすることで、キャッシュなしでインストールすることができます。

yarn install --no-cache

これで、パッケージをyarnでインストールすることができるようになりました!

まとめ

yarnをグローバルインストールするのはあんまり良くないのかなあ。
詳しい方教えてください。

参考

yarn add
yarn cache

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1