MENU

【備忘録】【rails6】Herokuへのデプロイエラー「error Command “webpack” not found.」

★環境
 Ruby:3.0.2
 Rails:6.1.4.1

目次

エラーが発生した背景

Herokuを使い始めて、アプリを初めてデプロイしたらエラーが発生しました。

Herokuへのデプロイエラー

-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
 !     Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
			Detected buildpacks: Ruby,Node.js
			See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
-----> Ruby app detected
-----> Installing bundler 2.2.21
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-3.0.2
-----> Installing dependencies using bundler 2.2.21
       Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
       Fetching gem metadata from https://rubygems.org/
       Fetching gem metadata from https://rubygems.org/..........
       Fetching rake 13.0.6
       Installing rake 13.0.6
       Fetching builder 3.2.4
       Fetching concurrent-ruby 1.1.9
       Fetching minitest 5.14.4
       Fetching zeitwerk 2.5.1
       Installing zeitwerk 2.5.1
       Installing builder 3.2.4
       Installing minitest 5.14.4
       Fetching erubi 1.10.0
       Fetching racc 1.6.0
       Installing concurrent-ruby 1.1.9
       Fetching crass 1.0.6
       Installing racc 1.6.0 with native extensions
       Installing erubi 1.10.0
       Installing crass 1.0.6
       Fetching rack 2.2.3
       Fetching nio4r 2.5.8
       Installing nio4r 2.5.8 with native extensions
       Installing rack 2.2.3
       Fetching websocket-extensions 0.1.5
       Installing websocket-extensions 0.1.5
       Fetching marcel 1.0.2
       Installing marcel 1.0.2
       Fetching mini_mime 1.1.2
       Fetching msgpack 1.4.2
       Installing mini_mime 1.1.2
       Installing msgpack 1.4.2 with native extensions
       Using bundler 2.2.22
       Fetching ffi 1.15.4
       Installing ffi 1.15.4 with native extensions
       Fetching method_source 1.0.0
       Installing method_source 1.0.0
       Fetching pg 1.2.3
       Installing pg 1.2.3 with native extensions
       Fetching thor 1.1.0
       Installing thor 1.1.0
       Fetching tilt 2.0.10
       Installing tilt 2.0.10
       Fetching semantic_range 3.0.0
       Installing semantic_range 3.0.0
       Fetching turbolinks-source 5.2.0
       Installing turbolinks-source 5.2.0
       Fetching rack-test 1.1.0
       Installing rack-test 1.1.0
       Fetching rack-proxy 0.7.0
       Installing rack-proxy 0.7.0
       Fetching websocket-driver 0.7.5
       Installing websocket-driver 0.7.5 with native extensions
       Fetching i18n 1.8.11
       Installing i18n 1.8.11
       Fetching tzinfo 2.0.4
       Installing tzinfo 2.0.4
       Fetching sprockets 4.0.2
       Installing sprockets 4.0.2
       Fetching mail 2.7.1
       Installing mail 2.7.1
       Fetching nokogiri 1.12.5 (x86_64-linux)
       Installing nokogiri 1.12.5 (x86_64-linux)
       Fetching puma 5.5.2
       Installing puma 5.5.2 with native extensions
       Fetching turbolinks 5.2.1
       Installing turbolinks 5.2.1
       Fetching activesupport 6.1.4.1
       Installing activesupport 6.1.4.1
       Fetching loofah 2.12.0
       Installing loofah 2.12.0
       Fetching bootsnap 1.9.1
       Installing bootsnap 1.9.1 with native extensions
       Fetching rails-dom-testing 2.0.3
       Installing rails-dom-testing 2.0.3
       Fetching globalid 0.5.2
       Installing globalid 0.5.2
       Fetching activemodel 6.1.4.1
       Installing activemodel 6.1.4.1
       Fetching jbuilder 2.11.3
       Installing jbuilder 2.11.3
       Fetching rails-html-sanitizer 1.4.2
       Installing rails-html-sanitizer 1.4.2
       Fetching activejob 6.1.4.1
       Installing activejob 6.1.4.1
       Fetching activerecord 6.1.4.1
       Installing activerecord 6.1.4.1
       Fetching actionview 6.1.4.1
       Installing actionview 6.1.4.1
       Fetching actionpack 6.1.4.1
       Installing actionpack 6.1.4.1
       Fetching actioncable 6.1.4.1
       Installing actioncable 6.1.4.1
       Fetching activestorage 6.1.4.1
       Installing activestorage 6.1.4.1
       Fetching actionmailer 6.1.4.1
       Installing actionmailer 6.1.4.1
       Fetching railties 6.1.4.1
       Installing railties 6.1.4.1
       Fetching sprockets-rails 3.4.0
       Installing sprockets-rails 3.4.0
       Fetching actionmailbox 6.1.4.1
       Installing actionmailbox 6.1.4.1
       Fetching actiontext 6.1.4.1
       Installing actiontext 6.1.4.1
       Fetching webpacker 5.4.3
       Installing webpacker 5.4.3
       Fetching rails 6.1.4.1
       Installing rails 6.1.4.1
       Fetching sassc 2.4.0
       Installing sassc 2.4.0 with native extensions
       Fetching sassc-rails 2.1.2
       Installing sassc-rails 2.1.2
       Fetching sass-rails 6.0.0
       Installing sass-rails 6.0.0
       Bundle complete! 18 Gemfile dependencies, 56 gems now installed.
       Gems in the groups 'development' and 'test' were not installed.
       Bundled gems are installed into `./vendor/bundle`
       Bundle completed (87.20s)
       Cleaning up the bundler cache.
       Removing bundler (2.2.21)
-----> Installing node-v16.13.1-linux-x64
-----> Installing yarn-v1.22.17
-----> Detecting rake tasks
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       yarn install v1.22.17
       warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
       [1/4] Resolving packages...
       warning @rails/webpacker > webpack > watchpack > watchpack-chokidar2 > chokidar > fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
       warning webpack-dev-server > webpack-log > uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
       error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`.
       info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
       I, [2022-01-04T13:11:37.836060 #1290]  INFO -- : Writing /tmp/build_c3204e57/public/assets/manifest-b4bf6e57a53c2bdb55b8998cc94cd00883793c1c37c5e5aea3ef6749b4f6d92b.js
       I, [2022-01-04T13:11:37.836432 #1290]  INFO -- : Writing /tmp/build_c3204e57/public/assets/manifest-b4bf6e57a53c2bdb55b8998cc94cd00883793c1c37c5e5aea3ef6749b4f6d92b.js.gz
       I, [2022-01-04T13:11:37.836647 #1290]  INFO -- : Writing /tmp/build_c3204e57/public/assets/application-1304083ae74ceba52744dbd1275698523f75dac2185642951234f6de027a8fc3.css
       I, [2022-01-04T13:11:37.836784 #1290]  INFO -- : Writing /tmp/build_c3204e57/public/assets/application-1304083ae74ceba52744dbd1275698523f75dac2185642951234f6de027a8fc3.css.gz
       I, [2022-01-04T13:11:37.836965 #1290]  INFO -- : Writing /tmp/build_c3204e57/public/assets/indexs-8adb8ce6c457daf6539c010c08bcd9f6178689acae5921110c6c9d0a46c8cf82.css
       I, [2022-01-04T13:11:37.837095 #1290]  INFO -- : Writing /tmp/build_c3204e57/public/assets/indexs-8adb8ce6c457daf6539c010c08bcd9f6178689acae5921110c6c9d0a46c8cf82.css.gz
       I, [2022-01-04T13:11:37.837268 #1290]  INFO -- : Writing /tmp/build_c3204e57/public/assets/indexs_sub-3ea047f01dab364120ce3b48543cac02bf6dfef54e5265f0f6c1092a2095d97b.css
       I, [2022-01-04T13:11:37.837376 #1290]  INFO -- : Writing /tmp/build_c3204e57/public/assets/indexs_sub-3ea047f01dab364120ce3b48543cac02bf6dfef54e5265f0f6c1092a2095d97b.css.gz
       Compiling...
       Compilation failed:
       yarn run v1.22.17
       info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
       
       
       error Command "webpack" not found.
       
 !
 !     Precompiling assets failed.
 !
 !     Push rejected, failed to compile Ruby app.
 !     Push failed

<原因>「webpack」が無かった

エラーメッセージにも書いてある通り「webpack」が無かったため、エラーが発生しました。

       error Command "webpack" not found.

<解決>「webpack」をインストール

無いものはインストールすればOKです。

Gemに「webpacker」を追加して「bundle install」してデプロイすればOKです。

gem 'webpacker'
bundle install
よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!

コメント

コメントする

目次