2014-01-16 63 views
2
[email protected]:~/Workspace/blog$ rails server 

/home/pallav/.rvm/gems/ruby-2.0.0-p353/gems/execjs-2.0.2/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable) 
    from /home/pallav/.rvm/gems/ruby-2.0.0-p353/gems/execjs-2.0.2/lib/execjs.rb:5:in `<module:ExecJS>' 
    from /home/pallav/.rvm/gems/ruby-2.0.0-p353/gems/execjs-2.0.2/lib/execjs.rb:4:in `<top (required)>' 
    from /home/pallav/.rvm/gems/ruby-2.0.0-p353/gems/uglifier-2.4.0/lib/uglifier.rb:3:in `require' 
    from /home/pallav/.rvm/gems/ruby-2.0.0-p353/gems/uglifier-2.4.0/lib/uglifier.rb:3:in `<top (required)>' 
    from /home/pallav/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `require' 
    from /home/pallav/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require' 
    from /home/pallav/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `each' 
    from /home/pallav/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `block in require' 
    from /home/pallav/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `each' 
    from /home/pallav/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `require' 
    from /home/pallav/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.5.2/lib/bundler.rb:131:in `require' 
    from /home/pallav/Workspace/blog/config/application.rb:7:in `<top (required)>' 
    from /home/pallav/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/commands.rb:74:in `require' 
    from /home/pallav/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/commands.rb:74:in `block in <top (required)>' 
    from /home/pallav/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/commands.rb:71:in `tap' 
    from /home/pallav/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/commands.rb:71:in `<top (required)>' 
    from bin/rails:4:in `require' 
    from bin/rails:4:in `<main>' 

[email protected]:~/Workspace/blog$ 

它甚至没有工作,我这样做:无法启动Rails的服务器 - 无法找到一个JavaScript运行

$创业板安装execjs

我的Gemfile包含此:

source 'https://rubygems.org' 

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 
gem 'rails', '4.0.2' 

# Use sqlite3 as the database for Active Record 
gem 'sqlite3' 

# Use SCSS for stylesheets 
gem 'sass-rails', '~> 4.0.0' 

# 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', '~> 1.2' 

group :doc do 
    # bundle exec rake doc:rails generates the API under doc/api. 
    gem 'sdoc', require: false 
end 

# Use ActiveModel has_secure_password 
# gem 'bcrypt-ruby', '~> 3.1.2' 

# Use unicorn as the app server 
# gem 'unicorn' 

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

# Use debugger 
# gem 'debugger', group: [:development, :test] 
+0

你可以发布你的Gemfile吗? – Agis

+0

https://docs.google.com/document/d/1dDBDBRc2_4-dFDI0dMLBfLg-BVWId0diH-Xsb2CZhD8/edit – PallavSharma

回答

8

您需要一个Javascript运行时。 Execjs实际上是您可以使用的各种运行时的包装。您仍然需要安装其中一个。几个系统已经带来了一个可用的系统(MacOS和Windows)。在其他人上,你需要安装一个。

在错误描述中,它指向https://github.com/sstephenson/execjs#readme,它描述了几个支持的运行时(提示:总是读取错误消息!)。在您的Gemfile中,您会注意到有引用的therubyracer gem(但注释掉了)。它是受支持的运行时间之一。

因此,你可以取消注释这个宝石,运行bundle install并设置。

15

您需要安装Javascript运行系统,例如Node.js例如:

$ sudo apt-get install nodejs 
+0

brew:找不到命令 – PallavSharma

+0

你在什么操作系统上? – Agis

+0

描述:\t Ubuntu 13.10 x86_64 – PallavSharma