无法运行Rails 4.1.7服务器

时间:2014-11-08 06:17:44

标签: ruby-on-rails ruby-on-rails-3

我已完成以下命令:

  1. rails new [app_name] [例如演示]

  2. cd demo [我进入了目录]

  3. rails -s(0r)rails -server

  4. 当我运行此命令时,我收到以下错误。

    /home/burhani/.rvm/gems/ruby-2.1.4/gems/execjs-2.2.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/burhani/.rvm/gems/ruby-2.1.4/gems/execjs-2.2.2/lib/execjs.rb:5:in `<module:ExecJS>'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/execjs-2.2.2/lib/execjs.rb:4:in `<top (required)>'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/uglifier-2.5.3/lib/uglifier.rb:3:in `require'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/uglifier-2.5.3/lib/uglifier.rb:3:in `<top (required)>'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/bundler-1.7.4/lib/bundler/runtime.rb:76:in `require'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/bundler-1.7.4/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/bundler-1.7.4/lib/bundler/runtime.rb:72:in `each'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/bundler-1.7.4/lib/bundler/runtime.rb:72:in `block in require'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/bundler-1.7.4/lib/bundler/runtime.rb:61:in `each'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/bundler-1.7.4/lib/bundler/runtime.rb:61:in `require'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/bundler-1.7.4/lib/bundler.rb:133:in `require'
    from /home/burhani/demo/config/application.rb:7:in `<top (required)>'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/railties-4.1.7/lib/rails/commands/commands_tasks.rb:79:in `require'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/railties-4.1.7/lib/rails/commands/commands_tasks.rb:79:in `block in server'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/railties-4.1.7/lib/rails/commands/commands_tasks.rb:76:in `tap'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/railties-4.1.7/lib/rails/commands/commands_tasks.rb:76:in `server'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/railties-4.1.7/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/railties-4.1.7/lib/rails/commands.rb:17:in `<top (required)>'
    from /home/burhani/demo/bin/rails:8:in `require'
    from /home/burhani/demo/bin/rails:8:in `<top (required)>'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `load'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `call'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/spring-1.1.3/lib/spring/client.rb:26:in `run'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/spring-1.1.3/bin/spring:48:in `<top (required)>'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `load'
    from /home/burhani/.rvm/gems/ruby-2.1.4/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `<top (required)>'
    from /home/burhani/demo/bin/spring:16:in `require'
    from /home/burhani/demo/bin/spring:16:in `<top (required)>'
    from bin/rails:3:in `load'
    from bin/rails:3:in `<main>'
    

    我想做什么。

    提前致谢。

1 个答案:

答案 0 :(得分:0)

您的错误Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)表示您没有安装Javascript运行时。安装Node.js(它也可用于其他目的)。在Ubuntu上:

$ curl -sL https://deb.nodesource.com/setup | sudo bash -
$ sudo apt-get install -y nodejs

此外,您还必须安装构建工具:

$ apt-get install -y build-essential

然后你就可以运行rails server命令。