もがき系プログラマの日常

もがき系エンジニアの勉強したこと、日常のこと、気になっている技術、備忘録などを紹介するブログです。

# yarn add ででた、error Extracting tar content of undefined failed, the file appears to be corrupt: "Unexpected end of data" の解決方法

こんばんは。

めちゃめちゃ短いですが、備忘録として残しておきます。

create-nuxt-appをglobalにインストールしようとしていたら、以下のようなエラーが発生してました。

$ yarn global add create-nuxt-app
yarn global v1.12.3
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
error https://registry.yarnpkg.com/event-stream/-/event-stream-3.3.6.tgz: Extracting tar content of undefined failed, the file appears to be corrupt: "Unexpected end of data"
info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.

ファイルが破損してるらしいんですが、今までyarnを使ってて出たことなかったので、調べていると以下のissueを見つけました。

https://github.com/eclipse/che/issues/12077

コメントで、大体yarn.lock消せって書いていたのですが、globalのyarn.lockってどこにあるのだろうと思って調べてると、丁寧にこのissueのコメントに書いてくれていました。

f:id:kojirooooocks:20190119020700p:plain

早速実行します。

$ yarn global dir
/path/to/.config/yarn/global

該当のディレクトリに行き調べるとたしかにありました。

$ cd /path/to/.config/yarn/global
$ ls
node_modules package.json yarn.lock

ここにある yarn.lock を削除して、再度、 yarn global add create-nuxt-app を実行します。

$ yarn global add create-nuxt-app
yarn global v1.12.3
[1/4] 🔍  Resolving packages...
warning @vue/cli > @vue/cli-ui > fkill > taskkill > execa > cross-spawn-async@2.2.5: cross-spawn no longer requires a build toolchain, use it instead
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
warning "@vue/cli > @vue/cli-ui > graphql-type-json@0.2.1" has unmet peer dependency "graphql@>=0.8.0".
warning "@vue/cli > @vue/cli-ui > graphql-tag@2.10.1" has unmet peer dependency "graphql@^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0".
warning "@vue/cli > @vue/cli-ui > vue-cli-plugin-apollo > apollo-server-express > apollo-server-core > apollo-tracing@0.4.0" has incorrect peer dependency "graphql@0.10.x - 14.0.x".
warning " > babel-jest@22.0.4" has unmet peer dependency "babel-core@^6.0.0 || ^7.0.0-0".
warning " > react-test-renderer@16.0.0" has unmet peer dependency "react@^16.0.0-beta.5".
[4/4] 📃  Building fresh packages...
success Installed "create-nuxt-app@2.2.0" with binaries:
      - create-nuxt-app
✨  Done in 194.88s.

 $ which create-nuxt-app 
/usr/local/bin/create-nuxt-app

インストールできました。

調べる過程で、yarn自体のupgradeとかもしましたが特に意味はなかったです。

やはり、このyarn.lockの削除が解決方法でした。

急に使えなくなったのでビビりましたが、落ち着いて調べたら簡単でした。

以上。おやすみなさい。