rails sでrailsを起動しようとしたらエラーがでました(☝ ՞ਊ ՞)
Could not find a JavaScript runtime エラーが発生
rails s
/home/vagrant/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/execjs-2.0.2/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)
/home/vagrant/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/execjs-2.0.2/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)
うーむエラーがでました。
gemのtherubyracerを有効にする
Gemfileにtherubyracerの項目がコメントされているのでコメントを削除します。
gem ‘therubyracer’, platforms: :ruby
その後で、bundle installを実行してみます。
bundle install
これでgemをインストールされます。
動作確認
rails sで動作確認しました。
rails s -p 8080
=> Booting WEBrick
=> Rails 4.0.2 application starting in development on http://0.0.0.0:8080
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2014-01-18 07:18:09] INFO WEBrick 1.3.1
[2014-01-18 07:18:09] INFO ruby 2.0.0 (2013-06-27) [x86_64-linux]
[2014-01-18 07:18:09] INFO WEBrick::HTTPServer#start: pid=1966 port=8080
=> Booting WEBrick
=> Rails 4.0.2 application starting in development on http://0.0.0.0:8080
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2014-01-18 07:18:09] INFO WEBrick 1.3.1
[2014-01-18 07:18:09] INFO ruby 2.0.0 (2013-06-27) [x86_64-linux]
[2014-01-18 07:18:09] INFO WEBrick::HTTPServer#start: pid=1966 port=8080
うまく起動できたみたいです(☝ ՞ਊ ՞)