代码之家  ›  专栏  ›  技术社区  ›  Mateusz Urbański

尝试加载宝石“uglifier”时出错。-沃克

  •  3
  • Mateusz Urbański  · 技术社区  · 9 年前

    我在将应用程序配置为用户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,但问题是我如何做到这一点?

    1 回复  |  直到 9 年前
        1
  •  2
  •   yez    9 年前

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

    你有几个选择:

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

    我会选择选项2,这样就不会给你的项目添加不必要的宝石。