ruby-on-rails - 无法运行资产:在heroku上预编译
问题描述
我正在 Rails 5.2.1 和 Ruby 2.4.4p296 下的 Windows 10 上开发 Rails 应用程序
我无法运行命令heroku run rake assets:precompile
我收到此错误:
C:\Users\Jaiel\Desktop\RubyOnRailsForum>heroku run rake assets:precompile --trace
Running rake assets:precompile --trace on ⬢ warm-mountain-15591... up, run.4644 (Free)
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke yarn:install (first_time)
** Execute yarn:install
Yarn executable was not detected in the system.
Download Yarn at https://yarnpkg.com/en/docs/install
** Execute assets:precompile
甚至是错误吗?heroku上的文件夹中有资产public/assets
,但是 JavaScript 文件似乎无法正常工作或相互冲突,因为我也遇到了问题。例如,method: :delete
在生产环境中的 Heroku 上的我的应用程序中,与 don't work 的链接。
解决方案
尝试这个
$rake assets:precompile (RAILS_ENV=production bundle exec rake assets:precompile is the exact rake task)
由于预编译仅在生产模式下完成,无需显式指定环境。
更新:
尝试将以下行添加到您的 Gemfile:
group :assets do
gem 'therubyracer'
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier'
end
然后运行捆绑安装。
希望它会工作:)
推荐阅读
- python - 时间序列:预测变量何时达到某个值(季节性传感器数据)python
- r - spotfire - 尝试做 kde 或只是弯曲线
- opencv - 正方体未发现错误:
未安装或不在您的 PATH 中 - node.js - Node JS:“electron.asar”文件的电子问题
- html - 过滤功能删除过滤词
- rust - 如何为 `<&Self as IntoIterator>` 绑定 `IntoIter` 类型?
- nginx - 通过 Nginx 代理的 API 请求需要 rfc1123 日期
- javascript - 在 plotly 饼图 hoverlabel 中增加填充 - javascript
- doctrine - Symfony 4 与 Doctrine 订阅者/听众的测试
- php - 如何通过终端访问 phpMyAdmin