ROR:rails server :Could not find a JavaScript runtime

来源:互联网 发布:什么是淘宝黑车 编辑:程序博客网 时间:2024/06/06 03:27

by http://www.88lei.com


$rails new demo

$cd demo

$rails server


/usr/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs/runtimes.rb:50:in `autodetect':Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

    from /usr/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs.rb:5:in `<module:ExecJS>'
    from /usr/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs.rb:4:in `<top (required)>'
    from /usr/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
    from /usr/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `<top (required)>'
    from /usr/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
    from /usr/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `<top (required)>'
    from /usr/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `require'
    from /usr/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `<top (required)>'
    from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:68:in `require'
    from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:66:in `each'
    from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:66:in `block in require'
    from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:55:in `each'
    from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:55:in `require'
    from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler.rb:122:in `require'
    from /home/acer/demo/config/application.rb:7:in `<top (required)>'
    from /usr/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/commands.rb:53:in `require'
    from /usr/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/commands.rb:53:in `block in <top (required)>'
    from /usr/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/commands.rb:50:in `tap'
    from /usr/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

acer@ubuntu:~/demo$ sudo gem install nodejs   ///提示找不到

下载node.js 源码:http://nodejs.org/#download  到node-v0.6.11.tar.gz

tar xzvf node-v0.6.11.tar.gz

cd node-v0.6.11

./configure

make

sudo make install

再 cd /home/acer/demo

执行 rails server

=> Booting WEBrick
=> Rails 3.2.1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-02-19 22:58:02] INFO  WEBrick 1.3.1
[2012-02-19 22:58:02] INFO  ruby 1.9.2 (2010-08-18) [i686-linux]
[2012-02-19 22:58:02] INFO  WEBrick::HTTPServer#start: pid=10637 port=3000


Started GET "/assets/rails.png" for 127.0.0.1 at 2012-02-19 23:00:33 +0800
Served asset /rails.png - 200 OK (41ms)

提示web server启动成功:

到firefox中打开http://localhost:3000 ,WOW! Rails 界面 出现了。

/////////////////////////////////////////////////////////////////////////////

execjs根据不同平台依赖不同的js runtime:
therubyracer - Google V8 embedded within Rubytherubyrhino - Mozilla Rhino embedded within JRubyJohnson - Mozilla SpiderMonkey embedded within RubyMustang - Mustang V8 embedded within RubyNode.jsApple JavaScriptCore - Included with Mac OS XMozilla SpiderMonkeyMicrosoft Windows Script Host (JScript)
http://www.88lei.com点击打开链接



原创粉丝点击