Could not find a JavaScript runtime

Hi,

I am trying to setup RoR on my test developer node, and I have some
difficulties when I created my new application. I noticed that the
“script”
directory is not created, which it does not allow me to start hosting
the
web page. I installed the ExecJS, but the ruby still not finding the
JavaScript runtime. I was trying to install nodejs from RHEL 6
repository
but I have multiples RPMs which I am not sure which is the correct one.
I
provided here some output errors for your review. Could you help me? Or
Do
you know who could help me?

Red Hat Enterprise Linux Server release 6.5 (Santiago)

ruby -v

ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

rails -v

Rails 4.1.6

gem list

*** LOCAL GEMS ***

actionmailer (4.1.6)

actionpack (4.1.6)

actionview (4.1.6)

activemodel (4.1.6)

activerecord (4.1.6)

activesupport (4.1.6)

arel (5.0.1.20140414130214)

bcrypt (3.1.7)

bigdecimal (1.2.4)

builder (3.2.2)

bundler (1.7.3)

capistrano (3.2.1)

capistrano-bundler (1.1.3)

capistrano-rails (1.1.2)

coffee-rails (4.0.1)

coffee-script (2.3.0)

coffee-script-source (1.8.0)

colorize (0.7.3)

columnize (0.8.9)

debugger-linecache (1.2.0)

debugger-ruby_core_source (1.3.5)

erubis (2.7.0)

execjs (2.2.1)

hike (1.2.3)

i18n (0.7.0.beta1, 0.6.11)

io-console (0.4.2)

java (0.0.2)

jbuilder (2.1.3)

jquery-rails (3.1.2)

json (1.8.1)

kgio (2.9.2)

libv8 (3.16.14.7 x86_64-linux)

mail (2.6.1)

mime-types (2.3)

minitest (5.4.2, 4.7.5)

multi_json (1.10.1)

mysql2 (0.3.16)

net-scp (1.2.1)

net-ssh (2.9.1)

psych (2.0.5)

rack (1.5.2)

rack-test (0.6.2)

rails (4.1.6)

railties (4.1.6)

raindrops (0.13.0)

rake (10.3.2, 10.1.0)

rdoc (4.1.2, 4.1.0)

ref (1.0.5)

rubygems-update (2.4.2)

sass (3.2.19)

sass-rails (4.0.3)

sdoc (0.4.1)

spring (1.1.3)

sprockets (2.12.2, 2.11.0)

sprockets-rails (2.1.4)

sqlite3 (1.3.9)

sshkit (1.5.1)

test-unit (2.1.2.0)

therubyracer (0.12.1)

thor (0.19.1)

thread_safe (0.3.4)

tilt (1.4.1)

turbolinks (2.4.0, 2.3.0)

tzinfo (1.2.2)

uglifier (2.5.3)

unicorn (4.8.3)

rails new contactlist

  create

  create  README.rdoc

  create  Rakefile

  create  config.ru

  create  .gitignore

  create  Gemfile

  create  app

  create  app/assets/javascripts/application.js

  create  app/assets/stylesheets/application.css

  create  app/controllers/application_controller.rb

  create  app/helpers/application_helper.rb

  create  app/views/layouts/application.html.erb

  create  app/assets/images/.keep

  create  app/mailers/.keep

  create  app/models/.keep

  create  app/controllers/concerns/.keep

  create  app/models/concerns/.keep

  create  bin

  create  bin/bundle

  create  bin/rails

  create  bin/rake

  create  config

  create  config/routes.rb

  create  config/application.rb

  create  config/environment.rb

  create  config/secrets.yml

  create  config/environments

  create  config/environments/development.rb

  create  config/environments/production.rb

  create  config/environments/test.rb

  create  config/initializers

  create  config/initializers/assets.rb

  create  config/initializers/backtrace_silencers.rb

  create  config/initializers/cookies_serializer.rb

  create  config/initializers/filter_parameter_logging.rb

  create  config/initializers/inflections.rb

  create  config/initializers/mime_types.rb

  create  config/initializers/session_store.rb

  create  config/initializers/wrap_parameters.rb

  create  config/locales

  create  config/locales/en.yml

  create  config/boot.rb

  create  config/database.yml

  create  db

  create  db/seeds.rb

  create  lib

  create  lib/tasks

  create  lib/tasks/.keep

  create  lib/assets

  create  lib/assets/.keep

  create  log

  create  log/.keep

  create  public

  create  public/404.html

  create  public/422.html

  create  public/500.html

  create  public/favicon.ico

  create  public/robots.txt

IT DOES NOT CREATE THE SCRIPT DIRECTORY

  create  test/fixtures

  create  test/fixtures/.keep

  create  test/controllers

  create  test/controllers/.keep

  create  test/mailers

  create  test/mailers/.keep

  create  test/models

  create  test/models/.keep

  create  test/helpers

  create  test/helpers/.keep

  create  test/integration

  create  test/integration/.keep

  create  test/test_helper.rb

  create  tmp/cache

  create  tmp/cache/assets

  create  vendor/assets/javascripts

  create  vendor/assets/javascripts/.keep

  create  vendor/assets/stylesheets

  create  vendor/assets/stylesheets/.keep

     run  bundle install

Don’t run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all
non-root
users

on this machine.

Fetching gem metadata from https://rubygems.org/
https://rubygems.org/

Resolving dependencies…

Using rake 10.3.2

Using i18n 0.6.11

Using json 1.8.1

Using minitest 5.4.2

Using thread_safe 0.3.4

Using tzinfo 1.2.2

Using activesupport 4.1.6

Using builder 3.2.2

Using erubis 2.7.0

Using actionview 4.1.6

Using rack 1.5.2

Using rack-test 0.6.2

Using actionpack 4.1.6

Using mime-types 2.3

Using mail 2.6.1

Using actionmailer 4.1.6

Using activemodel 4.1.6

Using arel 5.0.1.20140414130214

Using activerecord 4.1.6

Using bundler 1.7.3

Using coffee-script-source 1.8.0

Using execjs 2.2.1

Using coffee-script 2.3.0

Using thor 0.19.1

Using railties 4.1.6

Using coffee-rails 4.0.1

Using hike 1.2.3

Using multi_json 1.10.1

Using jbuilder 2.1.3

Using jquery-rails 3.1.2

Using tilt 1.4.1

Using sprockets 2.11.0

Using sprockets-rails 2.1.4

Using rails 4.1.6

Using rdoc 4.1.2

Using sass 3.2.19

Using sass-rails 4.0.3

Using sdoc 0.4.1

Using spring 1.1.3

Using sqlite3 1.3.9

Installing turbolinks 2.4.0

Using uglifier 2.5.3

Your bundle is complete!

Use bundle show [gemname] to see where a bundled gem is installed.

     run  bundle exec spring binstub --all
  • bin/rake: spring inserted

  • bin/rails: spring inserted

[ Linux : Thu Oct 02 20:34:26 : 0.15, 0.03, 0.01 :
~/rubydev/rails_projects ]

cd contactlist/

bundle exec spring binstub --all

  • bin/rake: spring already present

  • bin/rails: spring already present

ruby script / server Webrick

ruby: No such file or directory – script (LoadError)

ruby script/server Webrick

ruby: No such file or directory – script/server (LoadError)

rails server

/usr/local/lib/ruby/gems/2.1.0/gems/execjs-2.2.1/lib/execjs/runtimes.rb:51:in
`autodetect’: Could not find a JavaScript runtime. See
GitHub - sstephenson/execjs: Run JavaScript code from Ruby
https://github.com/sstephenson/execjs for a list of available
runtimes.
(ExecJS::RuntimeUnavailable)

    from

/usr/local/lib/ruby/gems/2.1.0/gems/execjs-2.2.1/lib/execjs.rb:5:in
`module:ExecJS

    from

/usr/local/lib/ruby/gems/2.1.0/gems/execjs-2.2.1/lib/execjs.rb:4:in
`<top
(required)>’

   from

/usr/local/lib/ruby/gems/2.1.0/gems/uglifier-2.5.3/lib/uglifier.rb:3:in
`require’

    from

/usr/local/lib/ruby/gems/2.1.0/gems/uglifier-2.5.3/lib/uglifier.rb:3:in
`<top (required)>’

    from

/usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.7.3/lib/bundler/runtime.rb:76:in
`require’

    from

/usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.7.3/lib/bundler/runtime.rb:76:in
`block (2 levels) in require’

    from

/usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.7.3/lib/bundler/runtime.rb:72:in
`each’

    from

/usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.7.3/lib/bundler/runtime.rb:72:in
`block in require’

    from

/usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.7.3/lib/bundler/runtime.rb:61:in
`each’

    from

/usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.7.3/lib/bundler/runtime.rb:61:in
`require’

    from

/usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.7.3/lib/bundler.rb:133:in
`require’

    from

/root/rubydev/rails_projects/contactlist/config/application.rb:7:in
`<top
(required)>’

    from

/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:79:in
`require’

    from

/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:79:in
`block in server’

    from

/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:76:in
`tap’

    from

/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:76:in
`server’

    from

/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:40:in
`run_command!’

    from

/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.6/lib/rails/commands.rb:17:in
`<top (required)>’

    from /root/rubydev/rails_projects/contactlist/bin/rails:8:in

`require’

    from /root/rubydev/rails_projects/contactlist/bin/rails:8:in 

`<top
(required)>’

    from

/usr/local/lib/ruby/gems/2.1.0/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in
`load’

    from

/usr/local/lib/ruby/gems/2.1.0/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in
`call’

    from

/usr/local/lib/ruby/gems/2.1.0/gems/spring-1.1.3/lib/spring/client/command.rb:7:in
`call’

    from

/usr/local/lib/ruby/gems/2.1.0/gems/spring-1.1.3/lib/spring/client.rb:26:in
`run’

    from

/usr/local/lib/ruby/gems/2.1.0/gems/spring-1.1.3/bin/spring:48:in `<top
(required)>’

    from

/usr/local/lib/ruby/gems/2.1.0/gems/spring-1.1.3/lib/spring/binstub.rb:11:in
`load’

    from

/usr/local/lib/ruby/gems/2.1.0/gems/spring-1.1.3/lib/spring/binstub.rb:11:in
`<top (required)>’

    from

/usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in
`require’

    from

/usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in
`require’

    from /root/rubydev/rails_projects/contactlist/bin/spring:16:in

`<top (required)>’

    from bin/rails:3:in `load'

    from bin/rails:3:in `<main>'

Thanks!

Hi Juan,

use this :-
-“gem install therubyracer”
-“bundle install”
-add “gem ‘therubyracer’” line in Gemfile which is located inside the
project
-rails server

WEBrick Server should start.

On 6 October 2014 11:36, Puneet Agarwal
[email protected] wrote:

Hi Juan,

use this :-
-“gem install therubyracer”
-“bundle install”
-add “gem ‘therubyracer’” line in Gemfile which is located inside the
project
-rails server

bundle install needs to be after adding therubyracer to Gemfile. Also
I don’t think you need to install therubyracer manually as bundle
install will do it.

Colin

Hey
I think i missed one line . Actually i stated 2 different ways to
resolve
the problem ,if you add in the gemfile then simply bundle install will
do
the work or you can manually install and add it to the gemfile. U can
choose any of the way . Better will be you add it in the gemfile and
then
run bundle install.

Thanks.

On 6 October 2014 14:44, Puneet Agarwal
[email protected] wrote:

Hey
I think i missed one line . Actually i stated 2 different ways to resolve
the problem ,if you add in the gemfile then simply bundle install will do
the work or you can manually install and add it to the gemfile. U can choose
any of the way . Better will be you add it in the gemfile and then run
bundle install.

I may be wrong but I think it will not work unless you add it to
Gemfile and bundle install

Colin

Hi,

To be specific it has to be included in gemfile and then running bundle
install will download and install the updated gem. Then javascript
runtime
error should go away. If you want any further clarifications let us
know.

Thanks.

On Sun, Oct 5, 2014 at 9:14 PM, Juan T. [email protected]
wrote:

I am trying to setup RoR on my test developer node, and I have some
difficulties when I created my new application. I noticed that the “script”
directory is not created, which it does not allow me to start hosting the
web page.

rails -v

Rails 4.1.6

It sounds like you’re using an out-of-date tutorial –

  create  bin
  create  bin/bundle
  create  bin/rails
  create  bin/rake

IT DOES NOT CREATE THE SCRIPT DIRECTORY

Exactly correct. Rails 4.0 and on don’t have a “script” directory;
it’s been replaced by “bin”.

ruby script/server Webrick

ruby: No such file or directory – script/server (LoadError)

That’s Rails < 4.0 syntax

You would start your local dev server with rails server (or rails s).
Try running rails --help for more info.

Don’t run Bundler as root.

There’s really no good reason to run development as root, at least
that I’ve ever seen; better to use a standard user account to limit the
possibility of accidental damage :slight_smile:

HTH and good luck,

Hassan S. ------------------------ [email protected]

twitter: @hassan

When we using Unix system for ror setup , we use therubyracer gem but
therubyracer is not working on the windows platform. On windows platform
use node-js.

Also other way is remove reuqire tree in application js file but this
not
correct way.