问题
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:
- If the links dont lead to a valid file, it compiles just fine.
- 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:
- 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.
- 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