ruby-on-rails - 尝试加载 gem 'uglifier' 时出错。 - 维尔克

标签 ruby-on-rails ruby wercker

我在为用户 wercker 配置我的应用程序时遇到问题。我的 wercker.yml 看起来像这样:

box: ruby
services:
  - postgres
build:
    steps:
        - script:
            name: Nokogiri fix
            code: bundle config build.nokogiri --use-system-libraries
        - bundle-install
        - rails-database-yml
        - script:
            name: Set up db
            code: bundle exec rake db:schema:load RAILS_ENV=test
        - script:
            name: rspec
            code: bundle exec rspec

当我运行构建时,它失败并出现以下错误:

rake aborted!
Bundler::GemRequireError: There was an error while trying to load the gem 'uglifier'.
/pipeline/source/config/application.rb:7:in `<top (required)>'
/pipeline/source/Rakefile:4:in `require'
/pipeline/source/Rakefile:4:in `<top (required)>'
ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
/pipeline/cache/bundle-install/ruby/2.3.0/gems/execjs-2.6.0/lib/execjs/runtimes.rb:48:in `autodetect'
/pipeline/cache/bundle-install/ruby/2.3.0/gems/execjs-2.6.0/lib/execjs.rb:5:in `<module:ExecJS>'
/pipeline/cache/bundle-install/ruby/2.3.0/gems/execjs-2.6.0/lib/execjs.rb:4:in `<top (required)>'
/pipeline/cache/bundle-install/ruby/2.3.0/gems/uglifier-2.7.2/lib/uglifier.rb:3:in `require'
/pipeline/cache/bundle-install/ruby/2.3.0/gems/uglifier-2.7.2/lib/uglifier.rb:3:in `<top (required)>'
/pipeline/source/config/application.rb:7:in `<top (required)>'
/pipeline/source/Rakefile:4:in `require'
/pipeline/source/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace

我认为我需要在 wercker 上安装 nodejs,但问题是我该怎么做?

最佳答案

正如对问题的评论所建议的,您需要安装一个 javascript 运行时。

您有几个选择:

  1. gem 'therubyracer' 添加到您的 Gemfile。
  2. 通过apt-get、brew等方式安装nodejs

我会选择选项 2,以免不必要地向您的项目添加 gem。

关于ruby-on-rails - 尝试加载 gem 'uglifier' 时出错。 - 维尔克,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36039547/

相关文章:

ruby - 如何在Ruby中调用另一个模块中定义的方法?

macos - Wercker在MacOS上因PANIC打开文件过多而崩溃

ruby-on-rails - 如何在 Rack 中间件中使用 cookie?

ruby-on-rails - heroku:Gemfile.lock 是必需的问题

ruby-on-rails - 强制 Bundler 安装本地 Ruby 版本支持的 gems

ruby-on-rails - 将嵌套数组的字符串表示形式转换为数组

ruby-on-rails - 用于 ruby​​ on rails 的 Mahout 插件

arrays - 将元素推到数组开头的最简单方法是什么?

git - 在 wercker 中仅构建 git 标签

docker - Docker + WerckerCi:找不到标签