Closed1

`git push heroku main`で発生した、`ENOENT`エラーへの対応

MASAMASA

事象

herokuへデプロイしようとするも、失敗。

$ sudo git push heroku main 
...(省略)...
remote:        [2/4] Fetching packages...
remote:        error https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz: 139844089067392:error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac:../deps/openssl/openssl/ssl/record/ssl3_record.c:677:
remote:        
remote:        info fsevents@2.3.1: The platform "linux" is incompatible with this module.
remote:        info "fsevents@2.3.1" is an optional dependency and failed compatibility check. Excluding it from installation.
remote:        info fsevents@1.2.13: The platform "linux" is incompatible with this module.
remote:        info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
remote:        [3/4] Linking dependencies...
remote:        warning " > webpack-dev-server@3.11.2" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
remote:        warning "webpack-dev-server > webpack-dev-middleware@3.7.3" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
remote:        error An unexpected error occurred: "ENOENT: no such file or directory, open '/app/.cache/yarn/v6/npm-picomatch-2.2.2-21f333e9b6b8eaff02468f5146ea406d345f4dad-integrity/node_modules/picomatch/.yarn-metadata.json'".
remote:        info If you think this is a bug, please open a bug report with the information provided in "/tmp/build_1d59c2e1/yarn-error.log".
remote:        info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
remote: 
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !       Push rejected to zero-training.
remote: 
To https://git.heroku.com/zero-training.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/zero-training.git'

最後のエラーから確認してみる。

remote:        error An unexpected error occurred: "ENOENT: no such file or directory, open '/app/.cache/yarn/v6/npm-picomatch-2.2.2-21f333e9b6b8eaff02468f5146ea406d345f4dad-integrity/node_modules/picomatch/.yarn-metadata.json'".

下記ファイルが見つからない。
/app/.cache/yarn/v6/npm-picomatch-2.2.2-21f333e9b6b8eaff02468f5146ea406d345f4dad-integrity/node_modules/picomatch/.yarn-metadata.json

エラー内容で検索すると、こちらのサイトにキャッシュを削除すればいいとある。
なので、キャッシュを削除する。

$ yarn cache clean
yarn cache v1.22.10
success Cleared cache.
Done in 2.23s.

再び、herokuへデプロイ。

$ sudo git push heroku main 
...(省略)...
remote: Verifying deploy... done.
To https://git.heroku.com/zero-training.git
   b1b9f95..7630b5d  main -> main

無事、デプロイできました!

このスクラップは2021/01/26にクローズされました