我正试图按照本教程部署一个基本的"你好,世界"使用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将webpack
和webpack-cli
包添加到package.json
文件中的依赖项中。但这无济于事。
我对编程很陌生,所以我可能会错过一些显而易见的东西。有人有什么线索吗?
谢谢!
更新:似乎问题的出现是因为我的主目录中有一个版本的yarn太新了。通过安装heroku试图在部署时运行的同一版本的yarn(v1.22.4(并将该版本用于yarn install
并更新yarn.lock文件,解决了问题。