我正在尝试根据Heroku guide for Rails 4设置我的资产管道,但是当我在控制台输入时:
rake assets:precompile RAILS_ENV=production
我收到此错误:
rake aborted!
ExecJS::ProgramError: SyntaxError: Unexpected token: eof (undefined) (line: 46, col: 0, pos: 1394)
Error
at new JS_Parse_Error (<eval>:3623:11948)
at js_error (<eval>:3623:12167)
at croak (<eval>:3623:22038)
at token_error (<eval>:3623:22175)
at unexpected (<eval>:3623:22263)
at block_ (<eval>:3623:28063)
at ctor.body (<eval>:3623:27686)
at function_ (<eval>:3623:27782)
at expr_atom (<eval>:3623:31068)
at maybe_unary (<eval>:3624:1752)
new JS_Parse_Error ((execjs):3623:11948)
js_error ((execjs):3623:12167)
croak ((execjs):3623:22038)
token_error ((execjs):3623:22175)
unexpected ((execjs):3623:22263)
block_ ((execjs):3623:28063)
ctor.body ((execjs):3623:27686)
function_ ((execjs):3623:27782)
expr_atom ((execjs):3623:31068)
maybe_unary ((execjs):3624:1752)
V8::Error: SyntaxError: Unexpected token: eof (undefined)
at js_error (<eval>:3623:12167)
at croak (<eval>:3623:22038)
at token_error (<eval>:3623:22175)
at unexpected (<eval>:3623:22263)
at block_ (<eval>:3623:28063)
at ctor.body (<eval>:3623:27686)
at function_ (<eval>:3623:27782)
at expr_atom (<eval>:3623:31068)
at maybe_unary (<eval>:3624:1752)
at expr_ops (<eval>:3624:2523)
at maybe_conditional (<eval>:3624:2615)
at maybe_assign (<eval>:3624:3058)
at expression (<eval>:3624:3384)
at expr_list (<eval>:3623:31548)
at subscripts (<eval>:3624:1461)
at expr_atom (<eval>:3623:31132)
at maybe_unary (<eval>:3624:1752)
at expr_ops (<eval>:3624:2523)
at maybe_conditional (<eval>:3624:2615)
at maybe_assign (<eval>:3624:3058)
at expression (<eval>:3624:3384)
at expr_atom (<eval>:3623:30820)
at maybe_unary (<eval>:3624:1752)
at expr_ops (<eval>:3624:2523)
at maybe_conditional (<eval>:3624:2615)
at maybe_assign (<eval>:3624:3058)
at expression (<eval>:3624:3384)
at simple_statement (<eval>:3623:25942)
at <eval>:3623:23902
at <eval>:3623:22954
at <eval>:3624:3759
at parse (<eval>:3624:3999)
at parse (<eval>:3958:22)
at uglifier (<eval>:4003:13)
Tasks: TOP => assets:precompile
我在SO上看过其他帖子,其中包含this和this等类似错误,但在这两种情况下,错误都足以说明错误所在的文件。我的错误,我没有看到对实际文件的引用,所以我很难过这里去的地方。
回想一下,当我开始尝试修复此问题时,它会显示一个文件(或其他内容),但我无法做出正面或反面(我也不知道为什么它会停止显示错误的位置。 ..):
Error
at new JS_Parse_Error (/private/var/folders/hz/1d1f64ln59b4_pl632lm6mpr0000gn/T/execjs20170121-47471-7jr3eejs:3623:11948)
at js_error (/private/var/folders/hz/1d1f64ln59b4_pl632lm6mpr0000gn/T/execjs20170121-47471-7jr3eejs:3623:12167)
at croak (/private/var/folders/hz/1d1f64ln59b4_pl632lm6mpr0000gn/T/execjs20170121-47471-7jr3eejs:3623:22038)
at token_error (/private/var/folders/hz/1d1f64ln59b4_pl632lm6mpr0000gn/T/execjs20170121-47471-7jr3eejs:3623:22175)
at unexpected (/private/var/folders/hz/1d1f64ln59b4_pl632lm6mpr0000gn/T/execjs20170121-47471-7jr3eejs:3623:22263)
at block_ (/private/var/folders/hz/1d1f64ln59b4_pl632lm6mpr0000gn/T/execjs20170121-47471-7jr3eejs:3623:28063)
at /private/var/folders/hz/1d1f64ln59b4_pl632lm6mpr0000gn/T/execjs20170121-47471-7jr3eejs:3623:27686
at function_ (/private/var/folders/hz/1d1f64ln59b4_pl632lm6mpr0000gn/T/execjs20170121-47471-7jr3eejs:3623:27782)
at expr_atom (/private/var/folders/hz/1d1f64ln59b4_pl632lm6mpr0000gn/T/execjs20170121-47471-7jr3eejs:3623:31068)
at maybe_unary (/private/var/folders/hz/1d1f64ln59b4_pl632lm6mpr0000gn/T/execjs20170121-47471-7jr3eejs:3624:1752)
new JS_Parse_Error ((execjs):3623:11948)
js_error ((execjs):3623:12167)
croak ((execjs):3623:22038)
token_error ((execjs):3623:22175)
unexpected ((execjs):3623:22263)
block_ ((execjs):3623:28063)
(execjs):3623:27686
function_ ((execjs):3623:27782)
expr_atom ((execjs):3623:31068)
maybe_unary ((execjs):3624:1752)
我查看了那里提到的目录,看不到相关文件。我搜索了我的整个系统“execjs20170121-47471-7jr3ee”和“execjs20170121-47471-7jr3eejs”但没有运气。
根据我在其他帖子中看到的内容,看起来Uglifier在解析我的Javascript时出错了,但同样,我只是不知道在哪里尝试修复它。
有什么想法吗?
答案 0 :(得分:-1)
我遇到了同样的问题。
您应该在生成日志中看到错误,因为您使用&#34; RAILS_ENV = production&#34;运行命令。
我的生产日志指向:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/execjs-2.7.0/lib/execjs/external_runtime.rb in exec at line 39
这是一行:
extract_result(@runtime.exec_runtime(filepath), filepath)
虽然这条线对我来说没有任何意义,但显而易见的是它是一个&#34; filepath&#34;问题。
有些字体可能未正确定义。
您应该使用<%= asset_path "..." %>
或sass-rails引用您的font-url,如here所述
如果仍然无效,请尝试更改:config.assets.compile = false
如here
config.assets.compile = true