When I try the command rails server on a new proje

2019-09-01 08:42发布

问题:

I am running Debian 7. I am using RVM. I am also running mySQL. I am new to ruby in general as well as rails. Please excuse any of me if I seem naive at all.

I setup a project with:
rails new projectname -d mysql

Then I went into that directory and ran:
rails server

I then get this error:

/home/user/.rvm/gems/ruby-2.0.0-p247/gems/execjs-2.0.0/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)
    from /home/user/.rvm/gems/ruby-2.0.0-p247/gems/execjs-2.0.0/lib/execjs.rb:5:in `'
    from /home/user/.rvm/gems/ruby-2.0.0-p247/gems/execjs-2.0.0/lib/execjs.rb:4:in `'
    from /home/user/.rvm/gems/ruby-2.0.0-p247/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
    from /home/user/.rvm/gems/ruby-2.0.0-p247/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `'
    from /home/user/.rvm/gems/ruby-2.0.0-p247/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
    from /home/user/.rvm/gems/ruby-2.0.0-p247/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `'
    from /home/user/.rvm/gems/ruby-2.0.0-p247/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `require'
    from /home/user/.rvm/gems/ruby-2.0.0-p247/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `'
    from /home/user/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
    from /home/user/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
    from /home/user/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
    from /home/user/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
    from /home/user/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
    from /home/user/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
    from /home/user/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
    from /home/user/htdocs/simple_cms/config/application.rb:7:in `'
    from /home/user/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.14/lib/rails/commands.rb:53:in `require'
    from /home/user/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.14/lib/rails/commands.rb:53:in `block in '
    from /home/user/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.14/lib/rails/commands.rb:50:in `tap'
    from /home/user/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.14/lib/rails/commands.rb:50:in `'
    from script/rails:6:in `require'
    from script/rails:6:in `'

I went to the link that was provided: https://github.com/sstephenson/execjs

The Read Me under Install says:
gem install execjs

I do this and still get the same error. I am lost.

回答1:

You have to first install a Javascript runtime, such as Node.js.

For Debian, there's installation instructions on Node.js Github

Edit: The ExecJS README lists the supported Javascript runtimes.



回答2:

I did install therubyracer. I put the necessary gems insides the projects gem file. This seems to have solved this issue.