jhicks2306
jhicks2306

Reputation: 101

error Command "webpack" not found - when deploying basic Rails app on Heroku

I am trying to follow this tutorial to deploy a basic "Hello, world!" app using Rails and Heroku.

I get to the git push heroku main command and hit the error message below when I run it.

remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        yarn install v1.22.4
remote:        [1/4] Resolving packages...
remote:        error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`.
remote:        info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
remote:        I, [2021-11-22T22:40:17.749803 #1743]  INFO -- : Writing /tmp/build_c74ce4bc/public/assets/manifest-b4bf6e57a53c2bdb55b8998cc94cd00883793c1c37c5e5aea3ef6749b4f6d92b.js
remote:        I, [2021-11-22T22:40:17.750027 #1743]  INFO -- : Writing /tmp/build_c74ce4bc/public/assets/manifest-b4bf6e57a53c2bdb55b8998cc94cd00883793c1c37c5e5aea3ef6749b4f6d92b.js.gz
remote:        I, [2021-11-22T22:40:17.750167 #1743]  INFO -- : Writing /tmp/build_c74ce4bc/public/assets/application-04024382391bb910584145d8113cf35ef376b55d125bb4516cebeb14ce788597.css
remote:        I, [2021-11-22T22:40:17.750260 #1743]  INFO -- : Writing /tmp/build_c74ce4bc/public/assets/application-04024382391bb910584145d8113cf35ef376b55d125bb4516cebeb14ce788597.css.gz
remote:        Compiling...
remote:        Compilation failed:
remote:        yarn run v1.22.4
remote:        info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
remote:
remote:
remote:        error Command "webpack" not found.
remote:
remote:
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.

I meet all of the Heroku tutorial's pre-requisites and I am using specific versions of ruby and Rails to match the Learn enough rails tutorial

$ ruby -v
ruby 2.7.4p191
$ rails -v
Rails 6.1.4.1
$ gem -v
3.2.31
$ Bundler -v
Bundler version 2.2.31

I've tried using yarn to add webpack and webpack-cli packages to dependencies in package.json file. But that hasn't helped.

I'm quite new to programming so I might be missing something obvious. Does anyone have any pointers?

Thank you!

Upvotes: 2

Views: 1309

Answers (1)

jhicks2306
jhicks2306

Reputation: 101

Update: Seemed the issue arose because I had a version of yarn in my home directory that was too recent. Resolved issue by installing same version of yarn that heroku tried to run at deployment (v1.22.4) and using this version to yarn install and update the yarn.lock file.

Upvotes: 0

Related Questions