0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Herokuへのデプロイでエラー発生 ⇨ ExecJS::RuntimeError: SyntaxError: Unexpected token punc «;», expected punc «)»

0
Last updated at Posted at 2020-01-22

はじめに

  • RailsチュートリアルでHerokuにデプロイする時にハマったエラー。
  • エラー発生箇所の特定に役立つ知識が得られた



ではエラー内容を見てみましょう。


エラー内容 1

コンソール
:
:
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
:
:

「アセットのプリコンパイルが失敗してますよ〜」
とのこと。


またエラーを上から見ていくと、こんなことも書かれている

エラー内容 2

コンソール
:
:
rake aborted!
ExecJS::RuntimeError: SyntaxError: Unexpected token punc «;», expected punc «)»
:
:

なるほど。どこかのJavascriptファイル内で構文エラーが発生しているらしい。
でもどのファイルかは教えてくれてないのね(T T)
じゃあ自分で調べて見ますか〜



エラー発生箇所の特定

Railsコンソール

JS_PATH = "app/assets/javascripts/**/*.js";
Dir[JS_PATH].each do |file_name|
  puts "\n#{file_name}"
  puts Uglifier.compile(File.read(file_name), harmony: true)
end

Railsコンソールを立ち上げて上のコードを実行します。

あーら不思議。エラーが発生しているファイルが表示される(はず)
あとは
➡︎ 特定したファイルを開く
➡︎ エラー箇所を修正
➡︎ Herokuへ push!

私はこの方法でエラー解消しました。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?