0
1

謎のUncaught SyntaxError: Unexpected token '<' エラーについて

Posted at

Uncaught SyntaxError: Unexpected token '<' エラー

Laravelで開発をしていたら突如コンソールに


Uncaught SyntaxError: Unexpected token '<'
    at Function (<anonymous>)
    at template.js:259:12
    at t.exports (_apply.js:13:25)
    at attempt.js:29:12
    at t.exports (_apply.js:15:25)
    at _overRest.js:32:12
    at t.exports (template.js:258:16)
    at t.value (Template.js:14:21)
    at station-list.js:11:4
    at station-list.js:1:20573

というエラーが起き、データがうまく出力されないといった現象に遭いました。

これがまた厄介でローカル環境では表示されるのに開発環境では表示されないのです。

色々試した結果

<% //コメント文 %>
↓に変更
<% /* コメント文 */ %>

すればうまく動作しました。

Underscore.jsやLodashなどのJavaScriptのテンプレートエンジンを使っている環境では
環境の差分によってこのようなエラーが起きるといった現象があるようです。

詳しい原因は追及する時間がなかったので省略...

私はこれを突き止めるまで1時間くらいかけてしまったので誰かのお役に立てれば幸いです...

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1