我刚刚安装了RoR,一切似乎都很好。但是当我最终加载所有内容时,要启动页面localhost:3000
我首先在命令提示符中出现此错误:
C:\ruby\rails\firstapp>rails server
C:/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.13.0.pre.1/lib/bundler/runtime.rb:89:
in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)
Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
Backtrace for gem load error is:
C:/ruby/lib/ruby/gems/2.1.0/gems/execjs-2.7.0/lib/execjs/runtimes.rb:58:in `autodetect'
C:/ruby/lib/ruby/gems/2.1.0/gems/execjs-2.7.0/lib/execjs.rb:5:in `<module:ExecJS>'
C:/ruby/lib/ruby/gems/2.1.0/gems/execjs-2.7.0/lib/execjs.rb:4:in `<top (required)>'
C:/ruby/lib/ruby/gems/2.1.0/gems/uglifier-3.0.0/lib/uglifier.rb:5:in `require'
C:/ruby/lib/ruby/gems/2.1.0/gems/uglifier-3.0.0/lib/uglifier.rb:5:in `<top (required)>'
C:/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.13.0.pre.1/lib/bundler/runtime.rb:86:
in `require'
C:/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.13.0.pre.1/lib/bundler/runtime.rb:86:
in `block (2 levels) in require'
C:/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.13.0.pre.1/lib/bundler/runtime.rb:81:
in `each'
C:/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.13.0.pre.1/lib/bundler/runtime.rb:81:
in `block in require'
C:/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.13.0.pre.1/lib/bundler/runtime.rb:70:
in `each'
C:/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.13.0.pre.1/lib/bundler/runtime.rb:70:
in `require'
C:/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.13.0.pre.1/lib/bundler.rb:104:in `req
uire'
C:/ruby/rails/firstapp/config/application.rb:7:in `<top (required)>'
C:/ruby/lib/ruby/gems/2.1.0/gems/railties-4.2.6/lib/rails/commands/commands_task
s.rb:78:in `require'
C:/ruby/lib/ruby/gems/2.1.0/gems/railties-4.2.6/lib/rails/commands/commands_task
s.rb:78:in `block in server'
C:/ruby/lib/ruby/gems/2.1.0/gems/railties-4.2.6/lib/rails/commands/commands_task
s.rb:75:in `tap'
C:/ruby/lib/ruby/gems/2.1.0/gems/railties-4.2.6/lib/rails/commands/commands_task
s.rb:75:in `server'
C:/ruby/lib/ruby/gems/2.1.0/gems/railties-4.2.6/lib/rails/commands/commands_task
s.rb:39:in `run_command!'
C:/ruby/lib/ruby/gems/2.1.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<to
p (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Bundler Error Backtrace:
from C:/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.13.0.pre.1/lib/bundler/r
untime.rb:85:in `block (2 levels) in require'
from C:/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.13.0.pre.1/lib/bundler/r
untime.rb:81:in `each'
from C:/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.13.0.pre.1/lib/bundler/r
untime.rb:81:in `block in require'
from C:/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.13.0.pre.1/lib/bundler/r
untime.rb:70:in `each'
from C:/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.13.0.pre.1/lib/bundler/r
untime.rb:70:in `require'
from C:/ruby/lib/ruby/gems/2.1.0/gems/bundler-1.13.0.pre.1/lib/bundler.r
b:104:in `require'
from C:/ruby/rails/firstapp/config/application.rb:7:in `<top (required)>
'
from C:/ruby/lib/ruby/gems/2.1.0/gems/railties-4.2.6/lib/rails/commands/
commands_tasks.rb:78:in `require'
from C:/ruby/lib/ruby/gems/2.1.0/gems/railties-4.2.6/lib/rails/commands/
commands_tasks.rb:78:in `block in server'
from C:/ruby/lib/ruby/gems/2.1.0/gems/railties-4.2.6/lib/rails/commands/
commands_tasks.rb:75:in `tap'
from C:/ruby/lib/ruby/gems/2.1.0/gems/railties-4.2.6/lib/rails/commands/
commands_tasks.rb:75:in `server'
from C:/ruby/lib/ruby/gems/2.1.0/gems/railties-4.2.6/lib/rails/commands/
commands_tasks.rb:39:in `run_command!'
from C:/ruby/lib/ruby/gems/2.1.0/gems/railties-4.2.6/lib/rails/commands.
rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
C:\ruby\rails\firstapp>
之后,我搜索页面localhost:3000
,除了显示页面错误之外什么都没有。
我虽然是问题的红宝石,所以我卸载了它,更改了版本(我现在使用的是2.1.8)并且仍然没有帮助。我真的需要帮助吗?
答案 0 :(得分:1)
osx:brew install nodejs
linux:sudo apt-get install nodejs
答案 1 :(得分:0)
您需要为Javascript运行时安装nodejs
答案 2 :(得分:0)
问题是您的环境缺少JavaScript运行时。它可以是其他答案所建议的node.js
,但并不仅限于此。
Execjs支持:
因此,您实际上可以使用一个非常适合您环境的运行时。