【问题标题】:error Command "webpack" not found - when deploying basic Rails app on Heroku找不到错误命令“webpack” - 在 Heroku 上部署基本 Rails 应用程序时
【发布时间】:2022-01-01 12:08:21
【问题描述】:

我正在尝试关注这个tutorial 来部署一个基本的“Hello, world!”使用 Rails 和 Heroku 的应用程序。

我到达git push heroku main 命令并在运行它时点击下面的错误消息。

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.

我满足 Heroku 教程的所有先决条件,并且我正在使用特定版本的 ruby​​ 和 Rails 来匹配 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

我尝试使用 yarn 将 webpackwebpack-cli 包添加到 package.json 文件中的依赖项。但这并没有帮助。

我对编程很陌生,所以我可能会遗漏一些明显的东西。有没有人指点一下?

谢谢!

【问题讨论】:

    标签: ruby-on-rails heroku webpack


    【解决方案1】:

    更新:似乎问题出现是因为我的主目录中有一个太新的 yarn 版本。通过安装 heroku 尝试在部署 (v1.22.4) 时运行的相同版本的 yarn 并将此版本用于 yarn install 并更新 yarn.lock 文件解决了问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-09
      • 2020-05-15
      • 2019-07-03
      • 1970-01-01
      • 2020-11-06
      • 2017-01-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多