Rails - Could not find a JavaScript runtime?
Installing a javascript runtime library such as nodejs solves this
To install nodejs on ubuntu, you can type the following command in the terminal:
sudo apt-get install nodejs
To install nodejs on systems using yum, type the following in the terminal:
yum -y install nodejs
Rails server does not start - Could not find a JavaScript runtime
I had the same error both for Windows and Ubuntu when I started working on Rails in January. The error is pretty straightforward. You need a JavaScript runtime environment for the server to start.
There are a number of solutions to this. The one I use on Ubuntu is to install NodeJS.
On Ubuntu you'd run something like the following to install NodeJS:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get -y update
sudo apt-get -y install nodejs
Those are the commands I use to do it as it will install the latest stable version of NodeJS, but you can just run sudo apt-get -y install nodejs
and be fine.
On Windows, the answer I used, and there may be others, was to edit your Gemfile to install therubyracer. I work on Rails 4.0 RC1 apps right now and they all have gem 'therubyracer', platform: :ruby
already in the Gemfile just commented out.
You can just go add gem 'therubyracer'
in your Gemfile if you're running on Windows and that will get you running I'd bet. Then run bundle install
.
Rails: Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
libv8
is an OS library; you'll need to install the correct Linux system library. If you're running Ubuntu, it's
sudo apt-get install libv8-dev
Alternatively, you can install node.js
which is available as a Debian/Ubuntu package for various distros, e.g. http://ppa.launchpad.net/chris-lea/node.js/ubuntu
You may save yourself a lot of trouble by deploying on Heroku instead where you don't have to manage the OS or components for gems.
Can't start Rails Server - Could not find a JavaScript runtime
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.
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.
Thus, you could just uncomment this gem, run bundle install
and be set.
Rails Server Could not find a JavaScript runtime
try to install latest nodejs.
more details can be found here ExecJS and could not find a JavaScript runtime
Phusion Passenger and Rails app using NVM Could not find a JavaScript runtime
I have the same problem and don't have a good solution but I did find I was able to get around my problem by creating a symbolic link like:
ln -sf /home/deploy/.nvm/versions/node/v6.10.1/bin/node /usr/local/bin/node
Doesn't work very well if there are multiple deployments on the same server but I also couldn't find a way to "properly" use NVM with Passenger / Rails.
First rails install: Rake aborted no javascript runtime
Try fix it:
/usr/local/lib/ruby/gems/ruby_ver/gems/execjs-ver/lib/execjs/runtimes.rb
Node = ExternalRuntime.new(
:name => "Node.js (V8)",
:command => ["nodejs", "/usr/local/bin/node"],
:runner_path => ExecJS.root + "/support/node_runner.js",
:encoding => 'UTF-8'
)
Related Topics
Initializing Instance Variable as an Array - Ruby
Cloning an Array with Its Content
Ruby on Rails:How to Implement Cancel Button in Form_Tag
What Purpose Can Anonymous Modules Serve
How to Replace an Array's Element
Solving Dependency Constraints
Did I Install Ruby 1.9.3 Correctly on Rhel
"The Ruby Way" (Mixins and Class Reopening) VS. Dependency Injection
Ruby - Open File, Find and Replace Multiple Lines
Ruby/Rails - How to Create a Class and Access It from the Controller
Ssl Error on Http Post (Unknown Protocol)
Why Does Psych Yaml Interpreter Add Line Breaks Around 80 Characters
How to Increment an Integer in Ruby
Ruby JSON.Pretty_Generate ... Is Pretty Unpretty
How to Daemonize Rails Rake Task on Elastic Beanstalk Start Up