admin管理员组文章数量:1323714
I am using coffeescript+ruby-on-rails. The pilation of coffeescript into pure JS leads to an error if there is a syntax problem in the coffee code. On the browser when I run the app, I get this error: ExecJS::RuntimeError
Is there any way to find out what caused the pilation error, when it was trying to pile coffee code to JS? Attached is a screenshot of the error
Following is the entry in the server log, which no way indicates the file which actually caused the syntax error:
ActionView::Template::Error (SyntaxError: [stdin]:25:10: unexpected :):
4: <meta name="viewport" content="width=device-width, initial-scale=1.0">
5: <title><%= content_for?(:title) ? yield(:title) : "Inmonarch Website" %></title>
6: <meta name="description" content="<%= content_for?(:description) ? yield(:description) : "Inmonarch Website" %>">
7: <%= stylesheet_link_tag 'application', media: 'all' %>
8: <%= javascript_include_tag 'application' %>
9: <%= csrf_meta_tags %>
10: </head>
app/views/layouts/dashboard.html.erb:7:in `_app_views_layouts_dashboard_html_erb__3120053487817944018_56303120'
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/_source.erb (7.4ms)
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (3.0ms)
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.6ms)
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb within rescues/layout (25.5ms)
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/web-console-2.3.0/lib/web_console/templates/_markup.html.erb (0.3ms)
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/web-console-2.3.0/lib/web_console/templates/_inner_console_markup.html.erb within layouts/inlined_string (0.3ms)
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/web-console-2.3.0/lib/web_console/templates/_prompt_box_markup.html.erb within layouts/inlined_string (0.3ms)
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/web-console-2.3.0/lib/web_console/templates/style.css.erb within layouts/inlined_string (0.3ms)
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/web-console-2.3.0/lib/web_console/templates/console.js.erb within layouts/javascript (296.8ms)
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/web-console-2.3.0/lib/web_console/templates/main.js.erb within layouts/javascript (0.2ms)
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/web-console-2.3.0/lib/web_console/templates/error_page.js.erb within layouts/javascript (0.3ms)
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/web-console-2.3.0/lib/web_console/templates/index.html.erb (313.8ms)
PS:- I know what the syntax error is, I made the syntax error deliberately to find out if I am able to trace the error with the help of logs, which I couldn't.
I am using coffeescript+ruby-on-rails. The pilation of coffeescript into pure JS leads to an error if there is a syntax problem in the coffee code. On the browser when I run the app, I get this error: ExecJS::RuntimeError
Is there any way to find out what caused the pilation error, when it was trying to pile coffee code to JS? Attached is a screenshot of the error
Following is the entry in the server log, which no way indicates the file which actually caused the syntax error:
ActionView::Template::Error (SyntaxError: [stdin]:25:10: unexpected :):
4: <meta name="viewport" content="width=device-width, initial-scale=1.0">
5: <title><%= content_for?(:title) ? yield(:title) : "Inmonarch Website" %></title>
6: <meta name="description" content="<%= content_for?(:description) ? yield(:description) : "Inmonarch Website" %>">
7: <%= stylesheet_link_tag 'application', media: 'all' %>
8: <%= javascript_include_tag 'application' %>
9: <%= csrf_meta_tags %>
10: </head>
app/views/layouts/dashboard.html.erb:7:in `_app_views_layouts_dashboard_html_erb__3120053487817944018_56303120'
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/_source.erb (7.4ms)
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (3.0ms)
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.6ms)
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb within rescues/layout (25.5ms)
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/web-console-2.3.0/lib/web_console/templates/_markup.html.erb (0.3ms)
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/web-console-2.3.0/lib/web_console/templates/_inner_console_markup.html.erb within layouts/inlined_string (0.3ms)
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/web-console-2.3.0/lib/web_console/templates/_prompt_box_markup.html.erb within layouts/inlined_string (0.3ms)
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/web-console-2.3.0/lib/web_console/templates/style.css.erb within layouts/inlined_string (0.3ms)
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/web-console-2.3.0/lib/web_console/templates/console.js.erb within layouts/javascript (296.8ms)
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/web-console-2.3.0/lib/web_console/templates/main.js.erb within layouts/javascript (0.2ms)
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/web-console-2.3.0/lib/web_console/templates/error_page.js.erb within layouts/javascript (0.3ms)
Rendered /home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/gems/web-console-2.3.0/lib/web_console/templates/index.html.erb (313.8ms)
PS:- I know what the syntax error is, I made the syntax error deliberately to find out if I am able to trace the error with the help of logs, which I couldn't.
Share Improve this question edited May 23, 2017 at 12:33 CommunityBot 11 silver badge asked Mar 12, 2016 at 8:42 Vipin VermaVipin Verma 5,73513 gold badges56 silver badges97 bronze badges 9- Here is a low-quality answer: from your data I feel that "SyntaxError: [stdin]:25:10: unexpected :" is interesting - you could dig to find that stdin and try to look around line 25, symbol 10 and something could be wrong with ':' symbol. You also have options to see 'Application Trace' 'Framework Trace' or 'Full Trace' - generaly those things have interesting info too. – Jaiden Snow Commented Mar 12, 2016 at 10:57
- Here is another low-quality method: you could reduce your coffeeScript step-by-step, throwing away feature-by-feature of your script until you get no pilation errors. This could indicate a place where things went wrong. You could use external syntax-checker tool to test your coffeeScript code as it seems that you have a syntax error. – Jaiden Snow Commented Mar 12, 2016 at 11:02
- 'Application Trace' 'Framework Trace' or 'Full Trace' doesn't have anything useful. 25:10 correctly says about the location of the error, but how do I get to know the file name in which the syntax error is present? What does [stdin] refer to? – Vipin Verma Commented Mar 12, 2016 at 11:03
- @Carpetsmoker I didn't include the code because it was not required. I know what the syntax error is, I made the syntax error deliberately to find out if I am able to trace the error with the help of logs, which I couldn't. Hence, I posted a question here. – Vipin Verma Commented Mar 14, 2016 at 5:21
- Probably, I was not clear enough. Sorry. – Vipin Verma Commented Mar 14, 2016 at 5:23
2 Answers
Reset to default 10One workaround is to pile your .coffee
files outside rails to get a decent error message:
If you don't yet have it:
npm i coffee-script -g
Then in a parent directory of your .coffee
files:
coffee --output deleteme --pile .
When you're done, delete the deleteme
folder it created (which is only created if you fix all the errors). This should find the syntax error for you and tell you exactly where it is.
You can use an online linter like http://www.coffeelint/ if you know its coffeescript causing the error
本文标签: javascriptCoffeescript compilation error in ruby on railsStack Overflow
版权声明:本文标题:javascript - Coffeescript compilation error in ruby on rails - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742127926a2422026.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论