0

我正在学习 RoR,生成控制器时出现错误

mitchell@ubuntu:~/Ruby/Website/blog$ rails generate controller posts

/home/mitchell/.rvm/gems/ruby-1.9.3-p327/gems/execjs-1.4.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/mitchell/.rvm/gems/ruby-1.9.3-p327/gems/execjs-1.4.0/lib/execjs.rb:5:in `<module:ExecJS>'
from /home/mitchell/.rvm/gems/ruby-1.9.3-p327/gems/execjs-1.4.0/lib/execjs.rb:4:in `<top (required)>'
from /home/mitchell/.rvm/gems/ruby-1.9.3-p327/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
from /home/mitchell/.rvm/gems/ruby-1.9.3-p327/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `<top (required)>'
from /home/mitchell/.rvm/gems/ruby-1.9.3-p327/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
from /home/mitchell/.rvm/gems/ruby-1.9.3-p327/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `<top (required)>'
from /home/mitchell/.rvm/gems/ruby-1.9.3-p327/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `require'
from /home/mitchell/.rvm/gems/ruby-1.9.3-p327/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `<top (required)>'
from /home/mitchell/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `require'
from /home/mitchell/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /home/mitchell/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in `each'
from /home/mitchell/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in `block in require'
from /home/mitchell/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `each'
from /home/mitchell/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `require'
from /home/mitchell/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.1/lib/bundler.rb:128:in `require'
from /home/mitchell/Ruby/Website/blog/config/application.rb:7:in `<top (required)>'
from /home/mitchell/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/commands.rb:24:in `require'
from /home/mitchell/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/commands.rb:24:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

我在 Ubuntu 上运行 Rails 3.2.9 和 Ruby 1.9.3。

4

1 回答 1

2

您的开发机器上缺少命令行 Javascript 解释器。

安装node.js,你应该会很好。

为了记录,这条信息似乎很清楚:

找不到 JavaScript 运行时。有关可用运行时的列表,请参阅https://github.com/sstephenson/execjs。(ExecJS::RuntimeUnavailable)

你去那个网址看看它说了什么吗?

一般来说,错误消息是非常有用的东西。当某些事情不起作用时,该消息应该告诉您原因,有时甚至告诉您如何解决它。

于 2012-11-13T21:29:43.623 回答