2012-04-07 101 views
7

当我发出命令“rails s”出现以下错误时请帮助我!我依然在轨项目,然后给这个命令Rails服务器无法启动?

[email protected]:~# cd mon 
[email protected]:~/mon# rails s 
/usr/lib/ruby/gems/1.8/gems/execjs-1.3.0/lib/execjs/runtimes.rb:50:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable) 
    from /usr/lib/ruby/gems/1.8/gems/execjs-1.3.0/lib/execjs.rb:5 
    from /usr/lib/ruby/gems/1.8/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require' 
    from /usr/lib/ruby/gems/1.8/gems/coffee-script-2.2.0/lib/coffee_script.rb:1 
    from /usr/lib/ruby/gems/1.8/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require' 
    from /usr/lib/ruby/gems/1.8/gems/coffee-script-2.2.0/lib/coffee-script.rb:1 
    from /usr/lib/ruby/gems/1.8/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `require' 
    from /usr/lib/ruby/gems/1.8/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1 
    from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `require' 
    from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `require' 
    from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `each' 
    from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `require' 
    from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `each' 
    from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `require' 
    from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler.rb:119:in `require' 
    from /root/mon/config/application.rb:7 
    from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/commands.rb:53:in `require' 
    from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/commands.rb:53 
    from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/commands.rb:50:in `tap' 
    from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/commands.rb:50 
    from script/rails:6:in `require' 
    from script/rails:6 

回答

11

添加

gem 'therubyracer' 

Gemfile和运行

bundle 

命令

+0

@ fl00r Hay感谢你们两位的工作......但是每次创建一个新项目时,我都必须将“gem therubyracer”添加到Gemfile中,为什么? – 2012-04-08 03:34:07

4

你需要安装一个JavaScript运行,如:

gem install therubyracer

http://nodejs.org/

这是由rails 3中的资产管道用于编译咖啡脚本。

+0

我安装therubyracer宝石,但仍然相同。 – 2012-04-08 03:10:41

+0

您是否将新的gem添加到您的'Gemfile'并删除了任何'Gemfile.lock'文件? – JellicleCat 2012-07-03 15:32:37