运行rails app时出错 - ExecJS :: RuntimeError

Joe*_*984 17 ruby ruby-on-rails ruby-on-rails-3.1

我试过谷歌搜索,我还没有找到答案我的问题.

我试图通过rails运行一个简单的控制器脚本,当我到达页面时它给了我这个错误.

ExecJS::RuntimeError in Say#hello
Run Code Online (Sandbox Code Playgroud)

显然Say是控制器,hello是方法.在页面的下方,我会获得有关错误的更多信息.

dyld: unknown required load command 0x80000022
(in /Users/JoeMoe/Sites/demoRails/app/assets/javascripts/say.js.coffee)
Run Code Online (Sandbox Code Playgroud)

我已经检查了这个文件,除了注释代码之外没有任何内容.那里应该有什么东西吗?

这是say.js.coffee文件中的内容

# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
Run Code Online (Sandbox Code Playgroud)

在页面下面我看到我可以做一个显示我的应用程序跟踪.

app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb__169683399_21885150'
Run Code Online (Sandbox Code Playgroud)

我也可以做框架跟踪.顺便说一句,这将是一个很长的清单.

execjs (1.2.9) lib/execjs/external_runtime.rb:129:in `exec_runtime'
execjs (1.2.9) lib/execjs/external_runtime.rb:27:in `block in exec'
execjs (1.2.9) lib/execjs/external_runtime.rb:40:in `compile_to_tempfile'
execjs (1.2.9) lib/execjs/external_runtime.rb:26:in `exec'
execjs (1.2.9) lib/execjs/external_runtime.rb:18:in `eval'
execjs (1.2.9) lib/execjs/external_runtime.rb:32:in `call'
coffee-script (2.2.0) lib/coffee_script.rb:57:in `compile'
tilt (1.3.3) lib/tilt/coffee.rb:46:in `evaluate'
tilt (1.3.3) lib/tilt/template.rb:76:in `render'
sprockets (2.0.3) lib/sprockets/context.rb:175:in `block in evaluate'
sprockets (2.0.3) lib/sprockets/context.rb:172:in `each'
sprockets (2.0.3) lib/sprockets/context.rb:172:in `evaluate'
sprockets (2.0.3) lib/sprockets/bundled_asset.rb:171:in`build_dependency_context_and_body'
sprockets (2.0.3) lib/sprockets/bundled_asset.rb:135:in `dependency_context'
....
Run Code Online (Sandbox Code Playgroud)

还有更多但很长的清单,我不想厌烦你.如果您需要完整列表,请告诉我,我会将其粘贴.

我使用以下内容运行Mac OS X - Ruby 1.9.2 - Rails 3.1.0 - Gem 1.8.10 - sqlite3 3.7.9

小智 20

你必须为javascript安装额外的gem.编辑gemfile并添加gem'therubyracer'.然后,您可以运行bundle来安装新的gem.

这是您的详细解决方案:http: //www.railszilla.com/2011/12/rails-3-coffescript-execjs/


小智 18

它也发生在我身上!您需要安装" nodejs ".当我使用Ubuntu Linux时,我做了:

apt-get install nodejs 
Run Code Online (Sandbox Code Playgroud)

来源:http://forums.pragprog.com/forums/148/topics/9665#posts-26576 (Sam Ruby的帖子)


Ale*_*eem 5

如果您在生产服务器中遇到此问题,则可能是由于内存使用情况.在做资产预编译服务器时使用大量内存.

consider restarting your production server. 
Run Code Online (Sandbox Code Playgroud)