私はHeroku、Nginx、Apache経由でレール/ブラウザアプリケーションをデプロイしようとしていましたが、同じエラーが発生しています。アセットがbundle exec rake assets:precompile db:migrate RAILS_ENV=production
でプリコンパイルされると、JSクラスの1つで構文エラーが発生します。私はここで似たような問題を発見しました:ES6 Classes: Unexpected token in script? しかし、私はコンストラクタやメソッドの外に変数宣言を持っていません。rails/browserifyアプリケーションでJavascript構文エラーが発生しました
エラー:構文エラー生成され
rake aborted!
ExecJS::RuntimeError: SyntaxError: Unexpected token: name (Game)
JS_Parse_Error.get ((execjs):3538:621)
(execjs):4060:47
(execjs):1:102
Object.<anonymous> ((execjs):1:120)
Module._compile (module.js:571:32)
Object.Module._extensions..js (module.js:580:10)
Module.load (module.js:488:32)
tryModuleLoad (module.js:447:12)
Function.Module._load (module.js:439:3)
Module.runMain (module.js:605:10)
JavaScriptクラス:
class Game {
constructor(attributes) {
this.id = attributes.id;
this.characters = attributes.characters;
this.quotes = attributes.game_quotes;
this.state = attributes.state;
this.completed = attributes.completed;
}
score() {
if (this.completed == true) {
var score = 0;
for (var i = 0; i < this.state.length; i++) {
if (this.state[i] == true) {
score++;
}
}
return score;
} else {
return "Game Incomplete";
}
}
percentageScore() {
if (this.score() >= 0) {
return (this.score() * 10 + "%");
} else {
return "Game Incomplete";
}
}
}
I構文エラー?ここで
あなたには、いくつかのコンテキストが必要な場合は自分のアプリケーションのリポジトリへのリンクです:Repository
コミュニティからの任意の助けいただければ幸いです。あなたがアドバイスを提供することができれば、事前に感謝します。