LoginSignup
0
1

yarn installの待機時間を延ばしてビルドを成功させるまで

Last updated at Posted at 2024-04-09

初めに

Next.jsの環境構築をDockerで行いました。以下の手順で進めていて、docker compose build を実行したときにエラーが起きたのでメモを残しておきます。

git clone
docker compose build

問題

Dockerビルドのプロセスで yarn install を実行しようとしたときに問題が起きました。

ERROR [front 5/5] RUN  yarn install 

 > [front 5/5] RUN  yarn install:                                                            
2.015 yarn install v1.22.19                                                                  
2.299 [1/4] Resolving packages...                                                            
2.807 [2/4] Fetching packages...                                                             
67.47 info There appears to be trouble with your network connection. Retrying...
92.78 info There appears to be trouble with your network connection. Retrying...
105.9 info There appears to be trouble with your network connection. Retrying...
126.2 info There appears to be trouble with your network connection. Retrying...
139.0 info There appears to be trouble with your network connection. Retrying...
159.3 info There appears to be trouble with your network connection. Retrying...
172.6 info There appears to be trouble with your network connection. Retrying...
192.8 info There appears to be trouble with your network connection. Retrying...
213.3 info If you think this is a bug, please open a bug report with the information provided in "/opt/app/yarn-error.log".
213.3 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
213.3 error An unexpected error occurred: "https://registry.yarnpkg.com/@mui/icons-material/-/icons-material-5.14.11.tgz: ESOCKETTIMEDOUT"
222.5 info There appears to be trouble with your network connection. Retrying...

原因

ネットワーク接続に問題があり、何度もアクセスを試みていました。着目していただきたいのが、以下エラーの内容です。@mui/icons-material/-/icons-material-5.14.11.tgzというパッケージのダウンロード時にESOCKETTIMEDOUT(ソケットタイムアウト)エラーが発生しています。これがインストール失敗の原因であることが分かります。

error An unexpected error occurred: 
"https://registry.yarnpkg.com/@mui/icons-material/-/icons-material-5.14.11.tgz: ESOCKETTIMEDOUT"

解決方法

.yarnrc ファイルをプロジェクトのルートディレクトリに作成して、以下設定を記述します。タイムアウトの時間を10分に変更して、タイムアウトによるエラーを回避することができました。今回は、@mui/icons-material/-/icons-material-5.14.11.tgzという大きなパッケージをインストールするのに時間が掛かっていました。

.yarnrc
network-timeout 600000

終わりに

yarn install はプロジェクトに必要な依存パッケージをインターネットからダウンロードし、インストールするプロセスです。大きなパッケージを扱う場合、ネットワーク速度が遅い場合に時間が掛かるみたいです。その際は、タイムアウトの時間をさらに延ばして、回避できそうです。

0
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
0
1