![](/img/trans.png)
[英]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.