本文介绍了Rake中止,尝试加载gem'uglifier'时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



 我试图在本地运行演示应用程序, $ bundle exec rake db:create db:migrate 

我得到

  sam @ samoliver:〜/ ruby​​-getting-started $ bundle exec rake db:create db:migrate --trace 
rake aborted!
Bundler :: GemRequireError:尝试加载gem'uglifier'时发生错误。
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:80:in`在区块(2个等级)中拯救需要'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:76:in`block(2 levels)in require'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:72:in`each'
/ home / sam /。 rvm / gems / ruby​​-2.2.3 / gems / bundler-1.11.0 / lib / bundler / runtime.rb:72:在`block in require'
/home/sam/.rvm/gems/ruby- 2.2.3 / gems / bundler-1.11.0 / lib / bundler / runtime.rb:61:在`each'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler- 1.11.0 / lib / bundler / runtime.rb:61:在`require'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler。 rb:99:在'require'
/home/sam/ruby-getting-started/config/application.rb:7:in`< top(required)>'
/ home / sam / ruby​​-getting-started / Rakefile:4:在'require'
/ home / sam / ruby​​-getting-started / Rakefile:4:在< top(required)>'
/家用/ SAM / .rvm /红宝石/红宝石-2.2.3 / lib中/红宝石/ 2.2.0 / rake / rake_module.rb:28:在`load'中
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/rake_module.rb: 28:在`load_rakefile'中
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:689:in`raw_load_rakefile'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:94:in`block in load_rakefile'
/home/sam/.rvm/ rubies / ruby​​-2.2.3 / lib / ruby​​ / 2.2.0 / rake / application.rb:176:在`standard_exception_handling'中
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ ruby / 2.2.0 / rake / application.rb:93:`load_rakefile'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application。 rb:77:在`block in run'中
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:176:in`standard_exception_handling'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:75:in`run'
/ home / sam /。 rvm / rubies / ruby​​-2.2.3 / bin / rake:33:在< main>中
ExecJS :: RuntimeUnavailable:找不到JavaScript运行时。有关可用运行时的列表,请参阅https://github.com/sstephenson/execjs。
/home/sam/.rvm/gems/ruby-2.2.3/gems/execjs-2.2.2/lib/execjs/runtimes.rb:51:in`autodetect'
/ home / sam /.rvm/gems/ruby-2.2.3/gems/execjs-2.2.2/lib/execjs.rb:5:in`< module:ExecJS>'
/home/sam/.rvm/gems /ruby-2.2.3/gems/execjs-2.2.2/lib/execjs.rb:4:in`< top(required)>'
/home/sam/.rvm/gems/ruby- 2.2.3 / gems / uglifier-2.5.3 / lib / uglifier.rb:3:在'require'
/home/sam/.rvm/gems/ruby-2.2.3/gems/uglifier-2.5。 3 / lib / uglifier.rb:3:在< top(required)>'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib /bundler/runtime.rb:77:in`require'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:77 :在`block(2 levels)in require'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:72:in `each'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:72:in`block in require'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:61:in`each'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:61:in`require'
/ home / sam /。 rvm / gems / ruby​​-2.2.3 / gems / bundler-1.11.0 / lib / bundler.rb:99:在'require'中
/home/sam/ruby-getting-started/config/application.rb :7:在'< top(required)>'
/ home / sam / ruby​​-getting-started / Rakefile:4:'require'
/ home / sam / ruby​​-getting-启动/ Rakefile:4:在< top(required)>'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/rake_module.rb :28:在`load'中
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/rake_module.rb:28:in`load_rakefile'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:689:in`raw_load_rakefile'
/home/sam/.rvm/rubies /ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:94:in`block in load_rakefile'
/home/sam/.rvm/rubies/ruby-2.2.3/lib /ruby/2.2.0/rake/application.rb:176:in` standard_exception_handling'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application .rb:93:在`lo ad_rakefile'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:77:in`block in run'
/ home /sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:176:in`standard_exception_handling'
/home/sam/.rvm/rubies/ruby- 2.2.3 / lib / ruby​​ / 2.2.0 / rake / application.rb:75:在'run'中
/home/sam/.rvm/rubies/ruby-2.2.3/bin/rake:33: '< main>'
sam @ samoliver:〜/ ruby​​-getting-start $

我尝试删除并重新添加'uglifier'(2.5.3),但没有安装'therubyracer',所以我不明白ExecJS抱怨什么。



Gemfile

  source'https://rubygems.org'
ruby​​'2.2.3'

#Bundle edge Rails改为:gem'rails',github:'rails / rails'
gem'rails','4.2.3'
#使用postgresql作为数据库for Active Record
gem'pg'
gem'rails_12factor',group :: production
#使用SCSS for样式表
gem'sass-rails','〜> 5.0.3'
#使用Uglifier作为JavaScript资源的压缩器
gem'uglifier','> = 1.3.0'
#使用CoffeeScript for .js.coffee资产和视图
gem'咖啡栏','〜> 4.0.0'
#请参阅https://github.com/sstephenson/execjs#readme以获得更多支持的运行时
#gem'therubyracer',平台:: ruby​​

#使用jquery作为JavaScript库
gem'jquery-rails'
#Turbolinks使Web应用程序中的以下链接更快。阅读更多:https://github.com/rails/turbolinks
gem'turbolinks'
#轻松构建JSON API。阅读更多:https://github.com/rails/jbuilder
gem'jbuilder','〜> 2.0'
#bundle exec rake doc:rails在doc / api下生成API。
gem'sdoc','〜> 0.4.0',组::doc

#Spring通过让应用程序在后台运行来加速开发速度。阅读更多:https://github.com/rails/spring
gem'spring',group::development

#使用ActiveModel has_secure_password
#gem'bcrypt',' 〜> 3.1.7'

gem'puma'

#使用Capistrano进行部署
#gem'capistrano-rails',group :: development

#使用调试器
#gem'debugger',group:[:development,:test]


解决方案

install nodejs

c $ c> apt-get install nodejs


I'm following 'Getting Started with Ruby on Heroku', but when attempting to run the demo app locally with

$ bundle exec rake db:create db:migrate

I get

sam@samoliver:~/ruby-getting-started$ bundle exec rake db:create db:migrate --trace
rake aborted!
Bundler::GemRequireError: There was an error while trying to load the gem 'uglifier'.
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:72:in `each'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:72:in `block in require'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:61:in `each'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:61:in `require'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler.rb:99:in `require'
/home/sam/ruby-getting-started/config/application.rb:7:in `<top (required)>'
/home/sam/ruby-getting-started/Rakefile:4:in `require'
/home/sam/ruby-getting-started/Rakefile:4:in `<top (required)>'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/rake_module.rb:28:in `load'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/rake_module.rb:28:in `load_rakefile'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:689:in `raw_load_rakefile'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:94:in `block in load_rakefile'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:93:in `load_rakefile'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:77:in `block in run'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/home/sam/.rvm/rubies/ruby-2.2.3/bin/rake:33:in `<main>'
ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
/home/sam/.rvm/gems/ruby-2.2.3/gems/execjs-2.2.2/lib/execjs/runtimes.rb:51:in `autodetect'
/home/sam/.rvm/gems/ruby-2.2.3/gems/execjs-2.2.2/lib/execjs.rb:5:in `<module:ExecJS>'
/home/sam/.rvm/gems/ruby-2.2.3/gems/execjs-2.2.2/lib/execjs.rb:4:in `<top (required)>'
/home/sam/.rvm/gems/ruby-2.2.3/gems/uglifier-2.5.3/lib/uglifier.rb:3:in `require'
/home/sam/.rvm/gems/ruby-2.2.3/gems/uglifier-2.5.3/lib/uglifier.rb:3:in `<top (required)>'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:77:in `require'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:77:in `block (2 levels) in require'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:72:in `each'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:72:in `block in require'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:61:in `each'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:61:in `require'
/home/sam/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.0/lib/bundler.rb:99:in `require'
/home/sam/ruby-getting-started/config/application.rb:7:in `<top (required)>'
/home/sam/ruby-getting-started/Rakefile:4:in `require'
/home/sam/ruby-getting-started/Rakefile:4:in `<top (required)>'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/rake_module.rb:28:in `load'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/rake_module.rb:28:in `load_rakefile'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:689:in `raw_load_rakefile'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:94:in `block in load_rakefile'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:93:in `load_rakefile'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:77:in `block in run'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/home/sam/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/home/sam/.rvm/rubies/ruby-2.2.3/bin/rake:33:in `<main>'
sam@samoliver:~/ruby-getting-started$

I tried removing and adding 'uglifier' (2.5.3) again to no effect and I do have 'therubyracer' installed, so I don't understand what is ExecJS complaining about.

Gemfile

source 'https://rubygems.org'
ruby '2.2.3'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3'
# Use postgresql as the database for Active Record
gem 'pg'
gem 'rails_12factor', group: :production
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring',        group: :development

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

gem 'puma'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]
解决方案

install nodejs

apt-get install nodejs

这篇关于Rake中止,尝试加载gem'uglifier'时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 04:49