为什么我会收到此错误?
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 `<top (required)>'
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 `<top (required)>'
from bin/rails:9:in `require'
from bin/rails:9:in `<main>
答案 0 :(得分:250)
您应该运行以下命令在Ubuntu中安装NodeJS
sudo apt-get install nodejs
或为OSX运行
brew install nodejs
Uglifier是一个JS包装器,需要运行JS运行时或JS解释器。我会选择安装NodeJS。
答案 1 :(得分:36)
在默认的Rails Gemfile中,gem'therubyracer'的行被注释掉了。如果你取消注释它,你将得到那个宝石,它应该工作。
来自“Getting Started with Rails”:
编译CoffeeScript和JavaScript资产压缩需要您的系统上有可用的JavaScript运行时,如果没有运行时,您将在资产编译期间看到
<ClientConfiguration xmlns="urn:orleans"> <SystemStore SystemStoreType ="SqlServer" DeploymentId="YYY" DataConnectionString="Server=THESERVER;Database=Orleans;User ID=USER;password=PASSWORD;" /> <GatewayProvider ProviderType="SqlServer"/> </ClientConfiguration>
错误。通常,Mac OS X和Windows都安装了JavaScript运行时。 Rails将execjs
gem添加到新应用的注释行中生成的therubyracer
,如果需要,可以取消注释。Gemfile
是JRuby用户的推荐运行时,默认情况下会添加到JRuby下生成的应用程序中的therubyrhino
。您可以在ExecJS调查所有支持的运行时。
答案 2 :(得分:-1)
创建数据库时出错。
问题是Node.js试图在脚本中没有sudo
安装:
sudo apt-get install nodejs