# Heroku 手動デプロイ ###### tags: `Heroku` ## チートシート ```bash= # アプリ一覧を表示 heroku apps # アプリを指定してアクティブにする heroku git:remote --app [アプリ名] # 例) heroku git:remote --app form-sales-bot-staging # Herokuにプッシュ (developブランチをアプリform-sales-bot-stagingのmasterブランチに) git push heroku develop:master # 上記例を打った後に叩くと、form-sales-bot-stagingに対してpushされる ``` ## デプロイエラー 上記、処理を行ってプッシュしようとしたらエラーになった ### デプロイブランチの選択エラー ```bash= Enumerating objects: 14168, done. Counting objects: 100% (14168/14168), done. Delta compression using up to 8 threads Compressing objects: 100% (3865/3865), done. Writing objects: 100% (14168/14168), 7.23 MiB | 3.10 MiB/s, done. Total 14168 (delta 9590), reused 14077 (delta 9536), pack-reused 0 remote: Compressing source files... done. remote: Building source: remote: remote: -----> Building on the Heroku-18 stack remote: -----> Using buildpacks: remote: 1. heroku/ruby remote: 2. heroku/nodejs remote: 3. https://github.com/heroku/heroku-buildpack-google-chrome remote: 4. https://github.com/heroku/heroku-buildpack-chromedriver remote: -----> Ruby app detected remote: -----> Installing bundler 1.17.3 remote: -----> Removing BUNDLED WITH version in the Gemfile.lock remote: -----> Compiling Ruby/Rails remote: -----> Using Ruby version: ruby-2.6.1 remote: -----> Installing dependencies using bundler 1.17.3 remote: Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 BUNDLE_GLOBAL_PATH_APPENDS_RUBY_SCOPE=1 bundle install -j4 remote: Fetching gem metadata from https://rubygems.org/....... remote: Your bundle is locked to mimemagic (0.3.3), but that version could not be found remote: in any of the sources listed in your Gemfile. If you haven't changed sources, remote: that means the author of mimemagic (0.3.3) has removed it. You'll need to update remote: your bundle to a version other than mimemagic (0.3.3) that hasn't been removed remote: in order to install. remote: Bundler Output: Fetching gem metadata from https://rubygems.org/....... remote: Your bundle is locked to mimemagic (0.3.3), but that version could not be found remote: in any of the sources listed in your Gemfile. If you haven't changed sources, remote: that means the author of mimemagic (0.3.3) has removed it. You'll need to update remote: your bundle to a version other than mimemagic (0.3.3) that hasn't been removed remote: in order to install. remote: remote: ! remote: ! Failed to install gems via Bundler. remote: ! remote: ! Push rejected, failed to compile Ruby app. remote: remote: ! Push failed remote: Verifying deploy... remote: remote: ! Push rejected to form-sales-bot-staging. remote: To https://git.heroku.com/form-sales-bot-staging.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/form-sales-bot-staging.git' ``` ##### 原因 ブランチ指定が間違っていた `git push heroku master`ではなく、`git push heroku develop:master`とする必要がある 詳細を書くと、`git push heroku [デプロイしたいリモートブランチ名] [Heroku App 個別のデプロイ先ブランチ]`となる ### :::spoiler エラー ```bash= remote: npm ERR! gyp verb extracted file from tarball x86/node.exe":"9bc93f97eccf3ac6b94c4a7e170e5b2c62cbad8abf4af65566c989d151008f9e","win-x86/node.lib":"8574cc9643d304df424d038f37b2a78cc3c2a7dd58c2f1b9ff5d9a07da73d80d","win-x86/node_pdb.7z":"1f5b95582d6a091b145212263be8ba7da6c1677607f65aa28df4b844a1329050","win-x86/node_pdb.zip":"4a99ae9b0d27d9402dc331fdcf8d22677af7a10eb309ac05ff2d6d1b24867334"} remote: npm ERR! gyp verb download contents checksum {"node-v16.15.1-headers.tar.gz":"535d0eddb5cde8445f198476aa240ccb7b59f1251f235408e84e940f84fb1c81"} remote: npm ERR! gyp verb validating download checksum for node-v16.15.1-headers.tar.gz (535d0eddb5cde8445f198476aa240ccb7b59f1251f235408e84e940f84fb1c81 == 535d0eddb5cde8445f198476aa240ccb7b59f1251f235408e84e940f84fb1c81) remote: npm ERR! gyp verb get node dir target node version installed: 16.15.1 remote: npm ERR! gyp verb build dir attempting to create "build" dir: /tmp/build_d4bf31f9/node_modules/node-sass/build remote: npm ERR! gyp verb build dir "build" dir needed to be created? /tmp/build_d4bf31f9/node_modules/node-sass/build remote: npm ERR! gyp verb build/config.gypi creating config file remote: npm ERR! gyp verb build/config.gypi writing out config file: /tmp/build_d4bf31f9/node_modules/node-sass/build/config.gypi remote: npm ERR! (node:3504) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only. remote: npm ERR! (Use `node --trace-deprecation ...` to show where the warning was created) remote: npm ERR! gyp verb config.gypi checking for gypi file: /tmp/build_d4bf31f9/node_modules/node-sass/config.gypi remote: npm ERR! gyp verb common.gypi checking for gypi file: /tmp/build_d4bf31f9/node_modules/node-sass/common.gypi remote: npm ERR! gyp verb gyp gyp format was not specified; forcing "make" remote: npm ERR! gyp info spawn /usr/bin/python2 remote: npm ERR! gyp info spawn args [ remote: npm ERR! gyp info spawn args '/tmp/build_d4bf31f9/node_modules/node-gyp/gyp/gyp_main.py', remote: npm ERR! gyp info spawn args 'binding.gyp', remote: npm ERR! gyp info spawn args '-f', remote: npm ERR! gyp info spawn args 'make', remote: npm ERR! gyp info spawn args '-I', remote: npm ERR! gyp info spawn args '/tmp/build_d4bf31f9/node_modules/node-sass/build/config.gypi', remote: npm ERR! gyp info spawn args '-I', remote: npm ERR! gyp info spawn args '/tmp/build_d4bf31f9/node_modules/node-gyp/addon.gypi', remote: npm ERR! gyp info spawn args '-I', remote: npm ERR! gyp info spawn args '/app/.node-gyp/16.15.1/include/node/common.gypi', remote: npm ERR! gyp info spawn args '-Dlibrary=shared_library', remote: npm ERR! gyp info spawn args '-Dvisibility=default', remote: npm ERR! gyp info spawn args '-Dnode_root_dir=/app/.node-gyp/16.15.1', remote: npm ERR! gyp info spawn args '-Dnode_gyp_dir=/tmp/build_d4bf31f9/node_modules/node-gyp', remote: npm ERR! gyp info spawn args '-Dnode_lib_file=/app/.node-gyp/16.15.1/<(target_arch)/node.lib', remote: npm ERR! gyp info spawn args '-Dmodule_root_dir=/tmp/build_d4bf31f9/node_modules/node-sass', remote: npm ERR! gyp info spawn args '-Dnode_engine=v8', remote: npm ERR! gyp info spawn args '--depth=.', remote: npm ERR! gyp info spawn args '--no-parallel', remote: npm ERR! gyp info spawn args '--generator-output', remote: npm ERR! gyp info spawn args 'build', remote: npm ERR! gyp info spawn args '-Goutput_dir=.' remote: npm ERR! gyp info spawn args ] remote: npm ERR! gyp verb command build [] remote: npm ERR! gyp verb build type Release remote: npm ERR! gyp verb architecture x64 remote: npm ERR! gyp verb node dev dir /app/.node-gyp/16.15.1 remote: npm ERR! gyp verb `which` succeeded for `make` /usr/bin/make remote: npm ERR! gyp info spawn make remote: npm ERR! gyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ] remote: npm ERR! ../src/libsass/src/cencode.c: In function ‘base64_encode_block’: remote: npm ERR! ../src/libsass/src/cencode.c:48:11: warning: this statement may fall through [-Wimplicit-fallthrough=] remote: npm ERR! result = (fragment & 0x003) << 4; remote: npm ERR! ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ remote: npm ERR! ../src/libsass/src/cencode.c:52:2: note: here remote: npm ERR! case step_B: remote: npm ERR! ^~~~ remote: npm ERR! ../src/libsass/src/cencode.c:62:11: warning: this statement may fall through [-Wimplicit-fallthrough=] remote: npm ERR! result = (fragment & 0x00f) << 2; remote: npm ERR! ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ remote: npm ERR! ../src/libsass/src/cencode.c:66:2: note: here remote: npm ERR! case step_C: remote: npm ERR! ^~~~ remote: npm ERR! In file included from /app/.node-gyp/16.15.1/include/node/v8.h:30:0, remote: npm ERR! from /app/.node-gyp/16.15.1/include/node/node.h:63, remote: npm ERR! from ../../nan/nan.h:54, remote: npm ERR! from ../src/binding.cpp:1: remote: npm ERR! /app/.node-gyp/16.15.1/include/node/v8-internal.h: In function ‘void v8::internal::PerformCastCheck(T*)’: remote: npm ERR! /app/.node-gyp/16.15.1/include/node/v8-internal.h:492:38: error: ‘remove_cv_t’ is not a member of ‘std’ remote: npm ERR! !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data); remote: npm ERR! ^~~~~~~~~~~ remote: npm ERR! /app/.node-gyp/16.15.1/include/node/v8-internal.h:492:38: note: suggested alternative: ‘remove_cv’ remote: npm ERR! !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data); remote: npm ERR! ^~~~~~~~~~~ remote: npm ERR! remove_cv remote: npm ERR! /app/.node-gyp/16.15.1/include/node/v8-internal.h:492:38: error: ‘remove_cv_t’ is not a member of ‘std’ remote: npm ERR! /app/.node-gyp/16.15.1/include/node/v8-internal.h:492:38: note: suggested alternative: ‘remove_cv’ remote: npm ERR! !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data); remote: npm ERR! ^~~~~~~~~~~ remote: npm ERR! remove_cv remote: npm ERR! /app/.node-gyp/16.15.1/include/node/v8-internal.h:492:50: error: template argument 2 is invalid remote: npm ERR! !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data); remote: npm ERR! ^ remote: npm ERR! /app/.node-gyp/16.15.1/include/node/v8-internal.h:492:63: error: ‘::Perform’ has not been declared remote: npm ERR! !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data); remote: npm ERR! ^~~~~~~ remote: npm ERR! /app/.node-gyp/16.15.1/include/node/v8-internal.h:492:63: note: suggested alternative: ‘herror’ remote: npm ERR! !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data); remote: npm ERR! ^~~~~~~ remote: npm ERR! herror remote: npm ERR! make: *** [Release/obj.target/binding/src/binding.o] Error 1 remote: npm ERR! gyp ERR! build error remote: npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2 remote: npm ERR! gyp ERR! stack at ChildProcess.onExit (/tmp/build_d4bf31f9/node_modules/node-gyp/lib/build.js:262:23) remote: npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:527:28) remote: npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12) remote: npm ERR! gyp ERR! System Linux 4.4.0-1103-aws remote: npm ERR! gyp ERR! command "/tmp/build_d4bf31f9/.heroku/node/bin/node" "/tmp/build_d4bf31f9/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library=" remote: npm ERR! gyp ERR! cwd /tmp/build_d4bf31f9/node_modules/node-sass remote: npm ERR! gyp ERR! node -v v16.15.1 remote: npm ERR! gyp ERR! node-gyp -v v3.8.0 remote: npm ERR! gyp ERR! not ok remote: npm ERR! Build failed with error code: 1 remote: remote: npm ERR! A complete log of this run can be found in: remote: npm ERR! /tmp/npmcache.W6oMm/_logs/2022-06-04T22_20_04_421Z-debug-0.log remote: remote: -----> Build failed remote: remote: We're sorry this build is failing! You can troubleshoot common issues here: remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys remote: remote: Some possible problems: remote: remote: - Node version not specified in package.json remote: https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version remote: remote: Love, remote: Heroku remote: remote: ! Push rejected, failed to compile Node.js app. remote: remote: ! Push failed remote: Verifying deploy... remote: remote: ! Push rejected to form-sales-bot-staging. remote: To https://git.heroku.com/form-sales-bot-staging.git ! [remote rejected] develop -> main (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/form-sales-bot-staging.git' ``` ::: ### 依存解決ができなかったエラー :::spoiler エラー ```bash= remote: npm ERR! code ERESOLVE remote: npm ERR! ERESOLVE could not resolve remote: npm ERR! remote: npm ERR! While resolving: eslint-loader@2.2.1 remote: npm ERR! Found: eslint@8.16.0 remote: npm ERR! node_modules/eslint remote: npm ERR! dev eslint@">=6.22.0" from the root project remote: npm ERR! peer eslint@">=5.7.0" from @nuxtjs/eslint-config@0.0.1 remote: npm ERR! node_modules/@nuxtjs/eslint-config remote: npm ERR! dev @nuxtjs/eslint-config@"^0.0.1" from the root project remote: npm ERR! 11 more (@typescript-eslint/experimental-utils, babel-eslint, ...) remote: npm ERR! remote: npm ERR! Could not resolve dependency: remote: npm ERR! peer eslint@">=1.6.0 <7.0.0" from eslint-loader@2.2.1 remote: npm ERR! node_modules/eslint-loader remote: npm ERR! dev eslint-loader@"^2.1.2" from the root project remote: npm ERR! remote: npm ERR! Conflicting peer dependency: eslint@6.8.0 remote: npm ERR! node_modules/eslint remote: npm ERR! peer eslint@">=1.6.0 <7.0.0" from eslint-loader@2.2.1 remote: npm ERR! node_modules/eslint-loader remote: npm ERR! dev eslint-loader@"^2.1.2" from the root project remote: npm ERR! remote: npm ERR! Fix the upstream dependency conflict, or retry remote: npm ERR! this command with --force, or --legacy-peer-deps remote: npm ERR! to accept an incorrect (and potentially broken) dependency resolution. remote: npm ERR! remote: npm ERR! See /tmp/npmcache.U2Cvi/eresolve-report.txt for a full report. remote: remote: npm ERR! A complete log of this run can be found in: remote: npm ERR! /tmp/npmcache.U2Cvi/_logs/2022-06-04T21_54_56_784Z-debug-0.log ``` ::: > Conflicting peer dependency: eslint@6.8.0 とは 参考:[Stack overflow / npmのhas unmet peer dependencyとは?](https://ja.stackoverflow.com/questions/52936/npm-%E3%81%AE-has-unmet-peer-dependency-%E3%81%A8%E3%81%AF%E3%81%A9%E3%81%86%E3%81%84%E3%81%86%E7%8A%B6%E6%85%8B%E3%81%A7%E3%81%99%E3%81%8B) npm audit fix --force ### peer, dev エラー :::spoiler エラー ```bash= npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: kaitak@1.0.0 npm ERR! Found: eslint@5.16.0 npm ERR! node_modules/eslint npm ERR! dev eslint@"^5.16.0" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer eslint@"^7.0.0 || ^8.0.0" from eslint-plugin-promise@6.0.0 npm ERR! node_modules/eslint-plugin-promise npm ERR! dev eslint-plugin-promise@">=4.3.1" from the root project npm ERR! npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this command with --force, or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution. npm ERR! npm ERR! See /Users/sakamoto/.npm/eresolve-report.txt for a full report. npm ERR! A complete log of this run can be found in: npm ERR! /Users/sakamoto/.npm/_logs/2022-06-04T23_50_24_215Z-debug-0.log ``` ::: この時点でのバージョン - eslint ^5.16 - eslint-plugin-promise >=4.3.1 > 原因