tag:crieit.net,2005:https://crieit.net/tags/.yarnrc/feed 「.yarnrc」の記事 - Crieit Crieitでタグ「.yarnrc」に投稿された最近の記事 2021-01-08T23:52:48+09:00 https://crieit.net/tags/.yarnrc/feed tag:crieit.net,2005:PublicArticle/16568 2021-01-08T23:52:48+09:00 2021-01-08T23:52:48+09:00 https://crieit.net/posts/yarn-error-there-appears-to-be-trouble-with-your-network-20210108 Yarn でパッケージをインストールする際に info There appears to be trouble with your network connection. Retrying... が出て失敗してしまう <p>Yarn でパッケージをインストールする際に</p> <blockquote> <p>info There appears to be trouble with your network connection. Retrying...</p> </blockquote> <p>が出て失敗してしまう現象に遭遇したので対処法をメモ。</p> <h2 id="現象"><a href="#%E7%8F%BE%E8%B1%A1">現象</a></h2> <p><code>package.json</code> が存在するプロジェクトで普通に <code>yarn</code> したら失敗しました。</p> <pre><code class="bash">> 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. </code></pre> <p>Webサイトは閲覧できるので接続自体は正常の模様。他の原因としては、「該当パッケージが重過ぎてダウンロード中にタイムアウトしてしまう」というケース。今回の場合は <code>@material-ui/icons</code> ですね。</p> <h2 id="対処"><a href="#%E5%AF%BE%E5%87%A6">対処</a></h2> <p>対処として、プロジェクト直下に <code>.yarnrc</code> というファイルを作成し、以下のように記述しました。</p> <pre><code class="yarnrc">network-timeout 600000 </code></pre> <p>単位はミリ秒なので、上記の場合は600秒、つまり10分となります。</p> <p>今回はこれで上手く行きました。</p> <h3 id="その他の対策"><a href="#%E3%81%9D%E3%81%AE%E4%BB%96%E3%81%AE%E5%AF%BE%E7%AD%96">その他の対策</a></h3> <p>ファイルを作成せずにコマンドの引数として渡すこともできるようです(未実施)。</p> <pre><code class="bash">> yarn config set network-timeout 600000 </code></pre> <p>または</p> <pre><code class="bash">> yarn install --network-timeout 600000 </code></pre> <h2 id="参考"><a href="#%E5%8F%82%E8%80%83">参考</a></h2> <h3 id=".yarnrc 設置"><a href="#.yarnrc+%E8%A8%AD%E7%BD%AE">.yarnrc 設置</a></h3> <ul> <li><a target="_blank" rel="nofollow noopener" href="https://qiita.com/GandT/items/9c2afa82609ff6062fd3">【Tips】yarn install時に発生しうるESOCKETTIMEDOUTの回避 - Qiita</a></li> <li><a target="_blank" rel="nofollow noopener" href="https://wonwon-eater.com/material-ui-lab-install/">yarn add @material-ui/labを実行するとThere appears to be trouble with your network connection. Retrying… │ wonwon eater</a></li> </ul> <h3 id="コマンドの引数"><a href="#%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%AE%E5%BC%95%E6%95%B0">コマンドの引数</a></h3> <ul> <li><a target="_blank" rel="nofollow noopener" href="https://blog.sa2taka.com/post/resolve-yarn-info-there-appears-to-be-trouble-with-your-network-connection-retrying">yarnを行うと「info There appears to be trouble with your network connection. Retrying...」が出てくる - 園児ニアの庭園</a></li> <li><a target="_blank" rel="nofollow noopener" href="http://rdrgn.hatenablog.com/entry/2018/11/06/000000">yarnに「There appears to be trouble with your network connection.」と言われたら - もふふのはてな</a></li> </ul> arm-band