无法启动 Rails Server - 找不到 JavaScript 运行时 [英] Can't start Rails Server - Could not find a JavaScript runtime

查看:94
本文介绍了无法启动 Rails Server - 找不到 JavaScript 运行时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

pallav@pallav-System-Product-Name:~/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>'

pallav@pallav-System-Product-Name:~/Workspace/blog$

即使我这样做也没有用:

It didn't worked even i did this:

$ gem install execjs

$ gem install execjs

我的 Gemfile 包含这个:

My Gemfile contains this:

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]

推荐答案

您需要一个 Javascript 运行时.Execjs 实际上是您可以使用的各种运行时的包装器.您仍然需要安装其中之一.一些系统已经提供了一个可用的系统(MacOS 和 Windows).在其他情况下,您需要安装一个.

You need a Javascript runtime. Execjs is in fact a wrapper around various runtimes you could use. You still need to install one of them. Several systems already bring a usable one (MacOS and Windows). On others, you need to install one.

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

In the error description, it pointed you towards https://github.com/sstephenson/execjs#readme which describes several of the supported runtimes (Hint: Always read error messages!). In your Gemfile, you'll notice that there is the therubyracer gem referenced (but commented out). It is one of the supported runtimes.

因此,您可以取消对此 gem 的注释,运行 bundle install 并进行设置.

Thus, you could just uncomment this gem, run bundle install and be set.

这篇关于无法启动 Rails Server - 找不到 JavaScript 运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆