歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Rails4.1.6啟動報錯Could not find a JavaScript runtime

Rails4.1.6啟動報錯Could not find a JavaScript runtime

日期:2017/2/28 14:28:04   编辑:Linux教程

我的電腦系統及Rails版本:CentOS 7,Rails4.1.6,Ruby2.0.0

1啟動服務器後報錯

#rails server

剛建的新項目,啟動服務報錯:

/home/oss/.gem/ruby/gems/execjs-2.2.1/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/oss/.gem/ruby/gems/execjs-2.2.1/lib/execjs.rb:5:in `<module:ExecJS>'

from /home/oss/.gem/ruby/gems/execjs-2.2.1/lib/execjs.rb:4:in `<top (required)等等

解決方法:

方法一:

1實際報錯信息都已經給出來了解決鏈接https://github.com/sstephenson/execjs,在上邊的報錯信息中

看過後直接安裝這個就行了therubyracer

參考該插件的說明:https://github.com/sstephenson/execjs#readme

安裝命令

#gem install therubyracer

過程的成功的信息如下:

[oss@localhost t9]$ gem install therubyracer

Fetching: ref-1.0.5.gem (100%)

Successfully installed ref-1.0.5

Fetching: libv8-3.16.14.7-x86_64-linux.gem (100%)

Successfully installed libv8-3.16.14.7-x86_64-linux

Fetching: therubyracer-0.12.1.gem (100%)

Building native extensions. This could take a while...

Successfully installed therubyracer-0.12.1

Parsing documentation for ref-1.0.5

Installing ri documentation for ref-1.0.5

Parsing documentation for libv8-3.16.14.7-x86_64-linux

Installing ri documentation for libv8-3.16.14.7-x86_64-linux

Parsing documentation for therubyracer-0.12.1

Installing ri documentation for therubyracer-0.12.1

Done installing documentation for ref, libv8, therubyracer after 1 seconds

3 gems installed

說明沒有問題,安張了三個gem都成功了

方法二:

(1)修改你新建的項目的根目錄下的Gemfile

# vi Gemfile

找到下面這行,把注釋去掉,

# gem 'therubyracer', platforms: :ruby

修改為

gem 'therubyracer', platforms: :ruby

保存退出 #wq

(2)用bundle安裝即可

#bundle install

參考rails4 Guides:http://guides.ruby-china.org/getting_started.html

方法三:

(3)把execjs和therubyracer都不要了,卸載掉然後安裝nodejs即可

官網http://nodejs.org/

下載後安裝就行了

#tar -xzvf node-v0.10.31.tar.gz

#cd node-v0.10.31

# ./configure

#make

#make install

Rails 的詳細介紹:請點這裡
Rails 的下載地址:請點這裡

Ubuntu下Apache服務器安裝以及使用Passenger插件部署Rails應用 http://www.linuxidc.com/Linux/2012-12/75230.htm

Ubuntu下搭建Ruby On Rails http://www.linuxidc.com/Linux/2012-06/61981.htm

Copyright © Linux教程網 All Rights Reserved