Yarn でパッケージをインストールする際に
info There appears to be trouble with your network connection. Retrying...
が出て失敗してしまう現象に遭遇したので対処法をメモ。
package.json
が存在するプロジェクトで普通に yarn
したら失敗しました。
> yarn
## 略
[2/4] Fetching packages...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
error An unexpected error occurred: "https://registry.yarnpkg.com/@material-ui/icons/-/icons-4.11.2.tgz: ESOCKETTIMEDOUT".
info If you think this is a bug, please open a bug report with the information provided in "PATH/TO/PROJECT/DIRECTORY/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Webサイトは閲覧できるので接続自体は正常の模様。他の原因としては、「該当パッケージが重過ぎてダウンロード中にタイムアウトしてしまう」というケース。今回の場合は @material-ui/icons
ですね。
対処として、プロジェクト直下に .yarnrc
というファイルを作成し、以下のように記述しました。
network-timeout 600000
単位はミリ秒なので、上記の場合は600秒、つまり10分となります。
今回はこれで上手く行きました。
ファイルを作成せずにコマンドの引数として渡すこともできるようです(未実施)。
> yarn config set network-timeout 600000
または
> yarn install --network-timeout 600000
Crieitは誰でも投稿できるサービスです。 是非記事の投稿をお願いします。どんな軽い内容でも投稿できます。
また、「こんな記事が読みたいけど見つからない!」という方は是非記事投稿リクエストボードへ!
こじんまりと作業ログやメモ、進捗を書き残しておきたい方はボード機能をご利用ください。
ボードとは?
コメント