簡體   English   中英

找不到錯誤命令“webpack” - 在 Heroku 上部署基本 Rails 應用程序時

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

我正在嘗試按照本教程部署一個基本的“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 教程

$ 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文件中的依賴項中。 但這並沒有幫助。

我對編程很陌生,所以我可能會遺漏一些明顯的東西。 有沒有人有任何指示?

謝謝!

更新:似乎問題出現了,因為我的主目錄中有一個太新的 yarn 版本。 通過安裝 heroku 在部署 (v1.22.4) 時嘗試運行的相同版本的 yarn 並使用此版本yarn install和更新 yarn.lock 文件解決了問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM