【问题标题】:Precompile error when push to Heroku Rails app with yarn使用 yarn 推送到 Heroku Rails 应用程序时出现预编译错误
【发布时间】:2021-03-13 11:10:12
【问题描述】:

我有一个 ROR 应用程序,我使用 yarn 安装了 toasterjQueryyarn add jquery ; yarn add toastr。还将它们的配置添加到 application.js:

// app/assets/application.js

//= require jquery
//= require rails-ujs
//= require activestorage
//= require turbolinks
//= require toastr/toastr

同时更新 application.scss:

app/assets/stylesheets/application.scss

@import "toastr/toastr";

应用在本地测试并且运行良好。但是当我尝试将它推送到 Heroku 时,我收到了这个错误:

remote:        Running: rake assets:precompile
remote:        Yarn executable was not detected in the system.
remote:        Download Yarn at https://yarnpkg.com/en/docs/install
remote:        I, [2020-12-01T12:43:31.158434 #1643]  INFO -- : Writing /tmp/build_7363272e/public/assets/application-2b2ad3277391444ddcebbd59536eb9b2f05b9a3ad61300e3ed828b7533f992fb.js
remote:        I, [2020-12-01T12:43:31.159231 #1643]  INFO -- : Writing /tmp/build_7363272e/public/assets/application-2b2ad3277391444ddcebbd59536eb9b2f05b9a3ad61300e3ed828b7533f992fb.js.gz
remote:        rake aborted!
remote:        SassC::SyntaxError: Error: File to import not found or unreadable: toastr/toastr.
remote:                on line 2:1 of app/assets/stylesheets/application.scss
remote:        >> @import "toastr/toastr";
...
remote:  !
remote:  !     Precompiling assets failed.
remote:  !

我需要做什么来解决这个问题?

【问题讨论】:

标签: ruby-on-rails heroku yarnpkg


【解决方案1】:

最好的方法是在 Heroku 中使用 elements.heroku.com/buildpacks/yarnpkg/yarn 这个 yarn build pack 并在推送到 Heroku 之前预编译所有资产,如果这不适合你,请继续使用这个 gem github.com/tylergannon/toastr-rails

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-22
    • 1970-01-01
    • 2021-08-26
    • 2015-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多