ExecJS 编译 Rails 3.1 资源时出现问题
我的 Rails 3.1.rc4 应用程序工作正常,但我正在尝试找出在管道中存储 js 文件的适当方法。如果我将任何代码放入 application.js 以外的文件中,则会收到以下错误:
于 2011 年 7 月 21 日开始获取 127.0.0.1 的“/assets/application.js” 23:15:02 -0500 已编译 〜/Dropbox/Rails/myapp/app/assets/javascripts/application.js.coffee (224ms)(pid 69397)编译资产application.js时出错: ExecJS::ProgramError: SyntaxError: 第 1 行保留字“function” (在 /Users/micahalcorn/Dropbox/Rails/myapp/app/assets/javascripts/users/registrations.js.coffee) 服务资产 /application.js - 500 内部服务器错误
无论哪个文件(在本例中是注册
)都会发生这种情况,并且无论文件中的第一个单词如何(var
、函数
等)。我使用node.js作为运行时环境,如果我删除coffeescript编译gems并将其视为Rails 3.0应用程序,一切都会正常工作。我想更好地了解资产管道并遵循惯例。感谢您的任何建议!
My Rails 3.1.rc4 app was working fine, but I'm trying to figure out the appropriate way to store my js files in the pipeline. If I put any code in a file other than application.js, I get the following error:
Started GET "/assets/application.js" for 127.0.0.1 at 2011-07-21
23:15:02 -0500 Compiled
~/Dropbox/Rails/myapp/app/assets/javascripts/application.js.coffee
(224ms) (pid 69397) Error compiling asset application.js:
ExecJS::ProgramError: SyntaxError: Reserved word "function" on line 1
(in
/Users/micahalcorn/Dropbox/Rails/myapp/app/assets/javascripts/users/registrations.js.coffee)
Served asset /application.js - 500 Internal Server Error
This happens regardless of which file (registrations
in this case) and claims a 'reserved word' regardless of the first word in the file (var
, function
, etc). I am using node.js as my runtime environment, and everything works fine if I remove coffeescript compiling gems and treat it like a Rails 3.0 app. I want to better understand the asset pipeline and follow conventions. Thanks for any suggestions!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该错误
是 CoffeeScript 编译器错误。将
registrations.js.coffee
中的function
转换为->
,或者将其重命名为registrations.js
该文件将被读取为原始 JavaScript。The error
is a CoffeeScript compiler error. Either convert
function
to->
inregistrations.js.coffee
, or rename it toregistrations.js
so that the file will be read as raw JavaScript.