Rails - Linking stylesheet and javascript in layout causes syntax error - “Missing ///”

筅森魡賤 提交于 2019-12-25 08:00:44

问题


I came into work today to find that my project is throwing a syntax error for some reason, and I can't find a single thing about this error.

When using the stylesheet_link_tag or javascript_include_tag helpers, I receive SyntaxError: [stdin]:1:1: missing ///.

Some things I have noted are:

  1. If the links dont lead to a valid file, it compiles just fine.
  2. Even if the files are empty the error is still thrown so the syntax error is definitely in the erb, even though I havent changed my application.html.erb since adding the link for the fonts.

EDIT:

  1. After rewriting the layout in haml, the error persists, so I suspect it is not in the erb but in the ruby functions for linking, although I don't know what could have changed.
  2. I just noticed the "ExecJs::RuntimeError", which is interesting because I commented out the javascript link so i could deal with one at a time.

Any help is appreciated. I feel like I'm missing somethinng very simple here, but i cant find it for the life of me.

If you want to see any of my code let me know, I wasnt sure what would be relevant other than this error page:

EDIT 2:
Here's my "appllication.html.erb":

<!DOCTYPE html>
<html xmlns="https://www.w3.org/1999/xhtml">
  <head>
    <title>{Site Name}</title>
    <%= csrf_meta_tags %>
    <link href="https://fonts.googleapis.com/css?family=Lato:400,300|Raleway|Tangerine:700" rel="stylesheet">
    <%= stylesheet_link_tag    "application.css", media: "all", "data-turbolinks-track": "reload" %>
    <%#<%= javascript_include_tag "application", 'data-turbolinks-track': 'reload' %>
  </head>
  <body>
    <%= yield %>
  </body>
</html>

回答1:


This error was caused by a compilation error somewhere in the rails asset pipeline. This specific instance was caused by a rogue TypeScript file in app/assets/javascripts after I had removed typescript-rails from my Gemfile.

Thanks to @dstarh I was able to find the error.

I'll leave this here since I couldn't find any information on this error anywhere. Hopefully it can help someone else.



来源:https://stackoverflow.com/questions/40312326/rails-linking-stylesheet-and-javascript-in-layout-causes-syntax-error-missi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!