LoginSignup
61
51

More than 5 years have passed since last update.

rails sコマンド実行時に「Could not find a JavaScript runtime.」とエラーが出る場合の対処法

Last updated at Posted at 2015-11-06
$ rails s
/usr/local/rvm/gems/ruby-2.1.5/gems/execjs-2.6.0/lib/execjs/runtimes.rb:48:in `autodetect': Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
        from /usr/local/rvm/gems/ruby-2.1.5/gems/execjs-2.6.0/lib/execjs.rb:5:in `<module:ExecJS>'
        from /usr/local/rvm/gems/ruby-2.1.5/gems/execjs-2.6.0/lib/execjs.rb:4:in `<top (required)>'
   (略)
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

Gemfileにgem 'therubyracer'という記述を追加して、bundle update以降の手順を同様に実行する。

JavaScriptランタイムがインストールされていないというエラーが表示された場合は、GitHubのexecjsページにあるインストール可能なランタイムを確認してください。Node.jsが特にお勧めです。

GitHub execjs
https://github.com/sstephenson/execjs

参考
http://pyoonn.hatenablog.com/entry/2014/10/17/165416


※追記

node.jsをインストールすれば、therubyracerをインストールしなくても大丈夫でした
(EC2 - Amazon Linuxの場合)

$ yum install nodejs --enablerepo=epel

で出来ると思います。

61
51
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
61
51