无法运行资产:在heroku上预编译

时间:2018-09-02 23:27:31

标签: ruby-on-rails heroku

我正在Windows 10上的Rails 5.2.1和Ruby 2.4.4p296上开发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上的我的App中不起作用。

Here is a thread about my problem that is maybe related to it

1 个答案:

答案 0 :(得分:0)

尝试一下

 $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

然后运行捆绑安装。

希望它会起作用:)