我试图运行rails generate rspec:install
,但我得到这个错误。我使用ruby 2.0.0p353和Rails 4.0.3。
错误是:
/home/adminuser/.rvm/珠宝/ruby-2.0.0-p353/珠宝/execjs-2.0.2/lib/execjs/运行时。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
'从/home/adminuser/.rvm/gems/ruby-2.0.0-p353/珠宝/execjs-2.0.2/lib/execjs。rb:4:在<top (required)>' from /home/adminuser/.rvm/gems/ruby-2.0.0-p353/gems/uglifier-2.4.0/lib/uglifier.rb:3:in
要求'从/home/adminuser/.rvm/gems/ruby-2.0.0-p353/珠宝/uglifier-2.4.0/lib/丑化的。rb:3:在<top (required)>' from /home/adminuser/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in
需要'从/home/adminuser/.rvm/gems/ruby-2.0.0-p353@global/珠宝/bundler-1.3.5/lib/打包机/运行时。rb:72:在block (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
每个'从/home/adminuser/.rvm/gems/ruby-2.0.0-p353@global/珠宝/bundler-1.3.5/lib/打包机/运行时。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
each'从/home/adminuser/.rvm/gems/ruby-2.0.0-p353@global/珠宝/bundler-1.3.5/lib/打包机/运行时。在require' from /home/adminuser/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.3.5/lib/bundler.rb:132:in
要求'从/home/adminuser/Desktop/667-workspace/assignment_3/config/应用程序。rb:12:在<top (required)>' from /home/adminuser/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.3/lib/rails/commands.rb:43:in
要求'从/home/adminuser/.rvm/gems/ruby-2.0.0-p353/珠宝/railties-4.0.3/lib/rails命令。rb:43:在<top (required)>' from bin/rails:4:in
要求From bin/rails:4:in "
正如错误提示的那样,您需要在本地机器上为JavaScript提供一个运行时(解释器)(不,浏览器中的解释器不会这样做)。
你可以通过安装gems(如therubyracer)或运行像sudo apt-get install nodejs这样的命令来实现这一点
为了运行rails生成器,您需要安装rubyracer或nodejs。我更喜欢nodejs,因为它可以在其他情况下使用,比如wer或npm
只需在项目中添加运行时
# Gemfile
gem 'therubyracer'