Rails4.1.6 startup error: cocould not find a JavaScript runtime

Source: Internet
Author: User
Tags ruby on rails

Rails4.1.6 startup error: cocould not find a JavaScript runtime

My computer system and Rails version: CentOS 7, Rails4.1.6, Ruby2.0.0

1. An error is reported after the server is started.

# Rails server

When you start a new project, the following error occurs:

/Home/oss /. gem/ruby/gems/execjs-2.2.1/lib/execjs/runtimes. rb: 51: in 'autodetect ': cocould 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) and so on

Solution:

Method 1:

1. The actual error message has been provided. The solution link is https://github.com/ssteenson/execjs, which is in the error message on the top.

After reading this, you can directly install this on therubyracer.

Refer to instructions for this plug-in: https://github.com/sstephenson/execjs#readme

Installation command

# Gem install therubyracer

The successful process information is as follows:

[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 cocould 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

It indicates that there is no problem. Three gems have been successfully installed.

Method 2:

(1) modify the Gemfile under the root directory of the new project.

# Vi Gemfile

Find the following line and remove the comment,

# Gem 'therubyracer', platforms: ruby

Change

Gem 'therubyracer', platforms: ruby

Save and exit # wq

(2) Use bundle for installation.

# Bundle install

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

Method 3:

(3) uninstall execjs and therubyracer and install nodejs.

Official http://nodejs.org/

Download and install it.

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

# Cd node-v0.10.31

#./Configure

# Make

# Make install

For details about Rails, click here
Rails: click here

Install Apache server in Ubuntu and use the Passenger plug-in to deploy Rails Applications

Build Ruby On Rails in Ubuntu

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.