尽管安装了therubyracer和nodejs,但找不到JavaScript运行时

时间:2021-06-10 22:42:24

I'm trying to run a Rails app on CentOS 5 and keep getting this error:

我正在尝试在CentOS 5上运行Rails应用程序并继续收到此错误:

Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

找不到JavaScript运行时。有关可用运行时的列表,请参阅https://github.com/sstephenson/execjs。 (ExecJS :: RuntimeUnavailable)

I have both NodeJS (v0.8.15) and therubyracer (libv8) installed.

我安装了NodeJS(v0.8.15)和therubyracer(libv8)。

Here is my gem list:

这是我的宝石清单:

*** LOCAL GEMS ***

actionmailer (3.2.9, 3.2.8)
actionpack (3.2.9, 3.2.8)
activemodel (3.2.9, 3.2.8)
activerecord (3.2.9, 3.2.8)
activerecord-sqlserver-adapter (3.2.10)
activeresource (3.2.9, 3.2.8)
activesupport (3.2.9, 3.2.8)
arel (3.0.2)
builder (3.1.4, 3.0.4)
bundler (1.2.3, 1.2.2)
capistrano (2.13.5)
commonjs (0.2.6)
daemon_controller (1.1.0)
diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.4.0)
factory_girl (4.1.0)
factory_girl_rails (4.1.0)
fastthread (1.0.7)
haml (3.1.7)
haml-rails (0.3.5)
highline (1.6.15)
hike (1.2.1)
i18n (0.6.1)
journey (1.0.4)
jquery-rails (2.1.4, 2.1.3)
json (1.7.5)
less (2.2.2)
less-rails (2.2.6)
libv8 (3.11.8.4)
mail (2.5.3, 2.4.4)
mime-types (1.19)
multi_json (1.5.0, 1.3.7)
net-scp (1.0.4)
net-sftp (2.0.5)
net-ssh (2.6.2, 2.6.1)
net-ssh-gateway (1.1.0)
nokogiri (1.5.6, 1.5.5)
passenger (3.0.18)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.2)
rails (3.2.9, 3.2.8)
railties (3.2.9, 3.2.8)
rake (10.0.3, 10.0.2, 10.0.1)
rdoc (3.12)
ref (1.0.2)
rspec-core (2.12.2, 2.12.0)
rspec-expectations (2.12.1, 2.12.0)
rspec-mocks (2.12.1, 2.12.0)
rspec-rails (2.12.0)
ruby-odbc (0.99994)
rubygems-bundler (1.1.0)
rvm (1.11.3.5)
sass (3.2.4, 3.2.3)
sass-rails (3.2.5)
sprockets (2.8.2, 2.2.2, 2.1.3)
sqlite3 (1.3.6)
therubyracer (0.11.0, 0.11.0beta8 x86-linux, 0.10.2)
thor (0.16.0)
tilt (1.3.3)
tiny_tds (0.5.1)
treetop (1.4.12)
twitter-bootstrap-rails (2.1.9, 2.1.6)
tzinfo (0.3.35)
uglifier (1.3.0)
webrat (0.7.3)
will_paginate (3.0.3)
will_paginate-bootstrap (0.2.1)

here is my gem file:

这是我的宝石文件:

source 'https://rubygems.org'

gem 'rails', '3.2.8'
gem 'haml'
gem 'will_paginate'
gem 'will_paginate-bootstrap'
gem 'activerecord-sqlserver-adapter'
gem 'ruby-odbc'
gem 'tiny_tds'
gem 'jquery-rails'
gem 'execjs'
gem 'therubyracer', :platforms => :ruby

group :assets do
  gem 'execjs'
  gem 'sass-rails'
  gem 'therubyracer', :platforms => :ruby
  gem 'uglifier'
  gem 'jquery-rails'
  gem 'twitter-bootstrap-rails'
end

group :test do
  gem 'rspec-rails'
  gem 'webrat'
  gem 'factory_girl_rails'
end    

group :development do
  gem 'rspec-rails'
  gem 'haml-rails'
end

What have I done wrong and what can I do to make execjs see any of JS runtime installed?

我做错了什么,我该怎么做才能使execjs看到任何JS运行时安装?

3 个解决方案

#1


2  

The simplest and fastest way to resolve this problem is just by installing NodeJS.

解决此问题的最简单,最快捷的方法就是安装NodeJS。

If you indeed have installed NodeJS, it may be an SElinux issue, try this:

如果你确实安装了NodeJS,它可能是一个SElinux问题,试试这个:

setenforce 0

#2


1  

How about the following answer: install execjs and it should use node automatically for you:

以下答案怎么样:安装execjs,它应该自动为您使用节点:

gem install execjs

alternatively you can also try installing therubyracer and include it in your gem file

或者您也可以尝试安装therubyracer并将其包含在您的gem文件中

gem install therubyracer

then add it in your Gemfile:

然后将其添加到您的Gemfile中:

gem "therubyracer"

source: https://teamtreehouse.com/forum/rails-server-error-could-not-find-a-javascript-runtime

来源:https://teamtreehouse.com/forum/rails-server-error-could-not-find-a-javascript-runtime

#3


-1  

Since no one can help directly with the problem, I've found solution of my own.

由于没有人可以直接帮助解决问题,我找到了自己的解决方案。

It's not directly solve described problem , but it worked for me

它不是直接解决所描述的问题,但它对我有用

I've reinstalled OS from centos to Ubuntu Server - issue not only disappear but general configuration of rails were flawless. After that I've set up about 20-30 servers some with very exotic software - no single issues I cannot find solution on the first page of google results. I guess that CentOS not really very suitable for Rails.

我重新安装了从centos到Ubuntu Server的操作系统 - 问题不仅消失了,而且导轨的一般配置完美无缺。之后我设置了大约20-30台服务器,其中一些使用非常奇特的软件 - 没有一个问题我在谷歌搜索结果的第一页找不到解决方案。我猜CentOS并不是非常适合Rails。

Hope this experience will help those who encounter the same problem.

希望这段经历能帮助那些遇到同样问题的人。

#1


2  

The simplest and fastest way to resolve this problem is just by installing NodeJS.

解决此问题的最简单,最快捷的方法就是安装NodeJS。

If you indeed have installed NodeJS, it may be an SElinux issue, try this:

如果你确实安装了NodeJS,它可能是一个SElinux问题,试试这个:

setenforce 0

#2


1  

How about the following answer: install execjs and it should use node automatically for you:

以下答案怎么样:安装execjs,它应该自动为您使用节点:

gem install execjs

alternatively you can also try installing therubyracer and include it in your gem file

或者您也可以尝试安装therubyracer并将其包含在您的gem文件中

gem install therubyracer

then add it in your Gemfile:

然后将其添加到您的Gemfile中:

gem "therubyracer"

source: https://teamtreehouse.com/forum/rails-server-error-could-not-find-a-javascript-runtime

来源:https://teamtreehouse.com/forum/rails-server-error-could-not-find-a-javascript-runtime

#3


-1  

Since no one can help directly with the problem, I've found solution of my own.

由于没有人可以直接帮助解决问题,我找到了自己的解决方案。

It's not directly solve described problem , but it worked for me

它不是直接解决所描述的问题,但它对我有用

I've reinstalled OS from centos to Ubuntu Server - issue not only disappear but general configuration of rails were flawless. After that I've set up about 20-30 servers some with very exotic software - no single issues I cannot find solution on the first page of google results. I guess that CentOS not really very suitable for Rails.

我重新安装了从centos到Ubuntu Server的操作系统 - 问题不仅消失了,而且导轨的一般配置完美无缺。之后我设置了大约20-30台服务器,其中一些使用非常奇特的软件 - 没有一个问题我在谷歌搜索结果的第一页找不到解决方案。我猜CentOS并不是非常适合Rails。

Hope this experience will help those who encounter the same problem.

希望这段经历能帮助那些遇到同样问题的人。