使用 yarn 推送到 Heroku Rails 应用程序时出现预编译错误
Precompile error when push to Heroku Rails app with yarn
我有一个 ROR 应用程序,我在其中安装了 toaster 和 jQuery 使用 yarn:yarn 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: !
我需要做什么来解决这个问题?
最好的方法是在 Heroku 中使用 elements.heroku.com/buildpacks/yarnpkg/yarn
这个纱线构建包并在推送到 Heroku 之前预编译所有资产,如果这对你不起作用,请继续使用这个 gem github.com/tylergannon/toastr-rails
我有一个 ROR 应用程序,我在其中安装了 toaster 和 jQuery 使用 yarn:yarn 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: !
我需要做什么来解决这个问题?
最好的方法是在 Heroku 中使用 elements.heroku.com/buildpacks/yarnpkg/yarn
这个纱线构建包并在推送到 Heroku 之前预编译所有资产,如果这对你不起作用,请继续使用这个 gem github.com/tylergannon/toastr-rails