[英]ExecJS::ProgramError: Unexpected token punc «(», expected punc «:» when running rake assets:precompile on production
[英]Can't Precompile Rails Assets Due to Uglifier Punc Error
這是我在在線 JavaScript Minifier 中從 public/assets/js 檢查我的 application.js 時收到的錯誤:
Parse error: Unexpected token: punc (})
Line 22315, column 33
22314: url: "/products/per_amount",
22315: data: {id: quantity, product},
22316: dataType: "json",
這看起來像這樣:
$.ajax({
url: "/products/per_amount",
data: {id: quantity, product},
dataType: "json",
type: "GET",
...
這是相同的錯誤這卻處處看着我說,這是固定或我試過的解決方案沒有奏效。
您似乎正在使用 Uglifier 不支持的 ES6 功能: http ://es6-features.org/#PropertyShorthand。
我認為 Uglifier 的目標是 ES5,除了 ES5 代碼外不會接受任何東西。 您可以通過在 ES5 中重寫代碼來快速修復:
$.ajax({
url: "/products/per_amount",
data: {id: quantity, product: product},
dataType: "json",
type: "GET",
如果您想保留您的語法優勢,請考慮使用 Babel 將您的代碼轉換為 ES5。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.