为什么我会收到此错误?
shibly@mybox:~/blog$ rails server /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError) from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require' from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each' from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require' from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each' from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require' from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler.rb:99:in `require' from /home/shibly/blog/config/application.rb:7:in `' from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:78:in `require' from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:78:in `block in server' from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `tap' from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `server' from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!' from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands.rb:17:in ` ' from bin/rails:9:in `require' from bin/rails:9:in `
Marcos Serpa.. 250
您应该运行以下命令在Ubuntu中安装NodeJS
sudo apt-get install nodejs
或者为OSX运行它
brew install nodejs
Uglifier是一个JS包装器,它需要运行JS运行时或JS解释器.我会选择安装NodeJS.
您应该运行以下命令在Ubuntu中安装NodeJS
sudo apt-get install nodejs
或者为OSX运行它
brew install nodejs
Uglifier是一个JS包装器,它需要运行JS运行时或JS解释器.我会选择安装NodeJS.
在默认的Rails Gemfile中,gem'therubyracer'的行被注释掉了.如果你取消注释它,你将得到那个宝石,它应该工作.
从" Rails入门 ":
编译CoffeeScript和JavaScript资产压缩需要您的系统上有可用的JavaScript运行时,如果没有运行时,您将
execjs
在资产编译期间看到错误.通常,Mac OS X和Windows都安装了JavaScript运行时.Rails将therubyracer
gem 添加到Gemfile
新应用程序的注释行中生成,如果需要,可以取消注释.therubyrhino
是JRuby用户的推荐运行时,默认情况下会添加到Gemfile
JRuby下生成的应用程序中.您可以在ExecJS上调查所有支持的运行时.