我试图运行rails generate rspec:install
,但我收到此错误。我使用的是ruby 2.0.0p353和Rails 4.0.3。
错误是:
/home/adminuser/.rvm/gems/ruby-2.0.0-p353/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) from /home/adminuser/.rvm/gems/ruby-2.0.0-p353/gems/execjs-2.0.2/lib/execjs.rb:5:in
&#39; 来自/home/adminuser/.rvm/gems/ruby-2.0.0-p353/gems/execjs-2.0.2/lib/execjs.rb:4:in<top (required)>' from /home/adminuser/.rvm/gems/ruby-2.0.0-p353/gems/uglifier-2.4.0/lib/uglifier.rb:3:in
要求&#39; 来自/home/adminuser/.rvm/gems/ruby-2.0.0-p353/gems/uglifier-2.4.0/lib/uglifier.rb:3:in<top (required)>' from /home/adminuser/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in
要求&#39; 来自/home/adminuser/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:inblock (2 levels) in require' from /home/adminuser/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in
每个&#39; 来自/home/adminuser/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:inblock in require' from /home/adminuser/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in
每个&#39; 来自/home/adminuser/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:inrequire' from /home/adminuser/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.3.5/lib/bundler.rb:132:in
要求&#39; 来自/home/adminuser/Desktop/667-workspace/assignment_3/config/application.rb:12:in<top (required)>' from /home/adminuser/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.3/lib/rails/commands.rb:43:in
要求&#39; 来自/home/adminuser/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.3/lib/rails/commands.rb:43:in<top (required)>' from bin/rails:4:in
要求&#39; 来自bin / rails:4:在`&#39;
答案 0 :(得分:2)
正如错误所示,您需要在本地计算机上使用JavaScript的运行时(解释器)(不,浏览器中的那些不会)。
你可以通过安装诸如therubyracer之类的宝石或像'sudo apt-get install nodejs'之类的运行命令来实现这一目的
答案 1 :(得分:1)
只需在项目中添加运行时
# Gemfile
gem 'therubyracer'
答案 2 :(得分:1)
您需要安装therubyracer或nodejs才能运行rails生成器。我更喜欢nodejs,因为它可以用于其他情况,例如bower或npm