LoginSignup
3
0

More than 3 years have passed since last update.

CI環境下のみ(?)発生するyarnエラー対策

Last updated at Posted at 2019-10-25

背景

あるリポジトリにScrutinizerを導入したら、最初のinspectから速攻コケました。

Buildが通らない。スコアが見れない。

こまった。

ということで、、、(?)

エラー原因を調査してみました。

エラー箇所

$ yarn install --force

Scrutinizer画面
Screen Shot 2019-10-24 at 14.18.11.png

エラー内容

Request failed、、404エラー、、ふむふむ。

error An unexpected error occurred: "https://registry.yarnpkg.com/sass/-/sass-1.22.8.tgz: Request failed \"404 Not Found\"".
info If you think this is a bug, please open a bug report with the information provided in "/home/scrutinizer/build/yarn-error.log".

原因

本記事末尾に貼っているyarnのリポジトリ内のissue[1][2]内に同様のエラーについて議論がされていました。

読み進めてみると yarn.lockが原因とのことです。

具体的には、
yarn install 実行時に参照される yarn.lock ファイル内にエラー文内の “https://registry.yarnpkg.com/sass/… “ のURLが記録されており、
ここから404エラーが出ていました。

解決策

yarn.lock を削除することで解決できます。

自分も同じ状況になりましたが、参考記事内でも述べられている通り、なぜかCI環境下でのみ発生します。

今回は Scrutinizer なので、Settings > Configuration 内に下記を追加しておしまいです。

build:
    ...
    dependencies:
        before:
            - rm yarn.lock
    ...

再inspect...

Screen Shot 2019-10-24 at 14.25.13.png

\ 🎉 /

おまけ

その1

ScrutinizerのConfigurationには様々な設定が可能です。
https://scrutinizer-ci.com/docs/configuration/build_reference
必要に応じて使いこなしたいですね。

その2

上記に示した解決策以外で試してみたものを下記に記します。

  • エラー文の上にwarningで package-lock.json が云々と書かれていたので、
    package-lock.jsonを消してから再inspectしましたが、
    warningが消えたのみで同エラーは発生したので、今回の問題とは関係なさそうです。

  • 別記事にまず yarn upgrade --latest をするとよい、みたいなことが書かれていたので、
    やってみましたが、こちらも今回のエラーには関係なさそうでした。

参考記事

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