I am running ruby 2.4.0 and rails 5 with uglifier >=1.3. My code works locally and will compile in development mode. But when I try to deploy it to DigitalOcean with Capistrano I get an error with precompiling assets.
我正在使用uglifier> = 1.3运行ruby 2.4.0和rails 5。我的代码在本地工作,将在开发模式下编译。但是当我尝试使用Capistrano将其部署到DigitalOcean时,我得到了预编译资产的错误。
Here is the error reproduced locally:
以下是本地转载的错误:
RAILS_ENV=production rake assets:clean assets:precompile
rake aborted!
ExecJS::RuntimeError: SyntaxError: Unexpected token: name (parent)
JS_Parse_Error.Object.defineProperty.get ((execjs):3538:621)
any ideas? Here is the output of the assets:precompile in production.
有任何想法吗?以下是资产的输出:生产中的预编译。
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Execute assets:precompile
rake aborted!
ExecJS::RuntimeError: SyntaxError: Unexpected token: name (parent)
JS_Parse_Error.Object.defineProperty.get ((execjs):3538:621)
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/execjs-2.7.0/lib/execjs/ruby_racer_runtime.rb:47:in `rescue in block in call'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/execjs-2.7.0/lib/execjs/ruby_racer_runtime.rb:44:in `block in call'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/execjs-2.7.0/lib/execjs/ruby_racer_runtime.rb:75:in `block in lock'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/execjs-2.7.0/lib/execjs/ruby_racer_runtime.rb:73:in `Locker'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/execjs-2.7.0/lib/execjs/ruby_racer_runtime.rb:73:in `lock'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/execjs-2.7.0/lib/execjs/ruby_racer_runtime.rb:43:in `call'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/uglifier-3.2.0/lib/uglifier.rb:195:in `run_uglifyjs'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/uglifier-3.2.0/lib/uglifier.rb:157:in `compile'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/uglifier_compressor.rb:53:in `call'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/uglifier_compressor.rb:28:in `call'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:75:in `call_processor'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `call_processors'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:60:in `block in load'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:44:in `load'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:47:in `load'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/base.rb:66:in `find_asset'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/base.rb:73:in `find_all_linked_assets'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:142:in `block in find'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:228:in `block in stat_tree'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `each'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `stat_directory'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:227:in `stat_tree'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in `each'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in `block in logical_paths'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in `each'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in `logical_paths'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:140:in `find'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:185:in `compile'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/rake/sprocketstask.rb:147:in `with_logger'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
/Users/Joseph/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/application.rb:108:in `each'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/application.rb:80:in `block in run'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/application.rb:77:in `run'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/Users/Joseph/.rvm/gems/ruby-2.4.0/bin/rake:22:in `load'
/Users/Joseph/.rvm/gems/ruby-2.4.0/bin/rake:22:in `<main>'
V8::Error: Unexpected token: name (parent)
at js_error (<eval>:3623:12181)
at croak (<eval>:3623:21897)
at token_error (<eval>:3623:22034)
at unexpected (<eval>:3623:22122)
at semicolon (<eval>:3623:22614)
at simple_statement (<eval>:3623:25718)
at <eval>:3623:23580
at <eval>:3623:22787
at block_ (<eval>:3623:27800)
at ctor.body (<eval>:3623:27403)
at function_ (<eval>:3623:27499)
at expr_atom (<eval>:3623:30759)
at maybe_unary (<eval>:3624:1514)
at expr_ops (<eval>:3624:2322)
at maybe_conditional (<eval>:3624:2414)
at maybe_assign (<eval>:3624:2815)
at expression (<eval>:3624:3128)
at expr_list (<eval>:3623:31239)
at subscripts (<eval>:3624:1223)
at subscripts (<eval>:3624:859)
at subscripts (<eval>:3624:1165)
at expr_atom (<eval>:3623:30896)
at maybe_unary (<eval>:3624:1514)
at expr_ops (<eval>:3624:2322)
at maybe_conditional (<eval>:3624:2414)
at maybe_assign (<eval>:3624:2815)
at expression (<eval>:3624:3128)
at simple_statement (<eval>:3623:25701)
at <eval>:3623:23580
at <eval>:3623:22787
at block_ (<eval>:3623:27800)
at ctor.body (<eval>:3623:27403)
at function_ (<eval>:3623:27499)
at expr_atom (<eval>:3623:30759)
at maybe_unary (<eval>:3624:1514)
at expr_ops (<eval>:3624:2322)
at maybe_conditional (<eval>:3624:2414)
at maybe_assign (<eval>:3624:2815)
at expression (<eval>:3624:3128)
at expr_list (<eval>:3623:31239)
at subscripts (<eval>:3624:1223)
at subscripts (<eval>:3624:859)
at subscripts (<eval>:3624:1165)
at expr_atom (<eval>:3623:30896)
at maybe_unary (<eval>:3624:1514)
at expr_ops (<eval>:3624:2322)
at maybe_conditional (<eval>:3624:2414)
at maybe_assign (<eval>:3624:2815)
at expression (<eval>:3624:3128)
at simple_statement (<eval>:3623:25701)
at <eval>:3623:23580
at <eval>:3623:22787
at <eval>:3624:3503
at parse (<eval>:3624:3743)
at parse (<eval>:3959:22)
at uglifier (<eval>:4007:13)
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/execjs-2.7.0/lib/execjs/ruby_racer_runtime.rb:45:in `block in call'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/execjs-2.7.0/lib/execjs/ruby_racer_runtime.rb:75:in `block in lock'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/execjs-2.7.0/lib/execjs/ruby_racer_runtime.rb:73:in `Locker'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/execjs-2.7.0/lib/execjs/ruby_racer_runtime.rb:73:in `lock'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/execjs-2.7.0/lib/execjs/ruby_racer_runtime.rb:43:in `call'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/uglifier-3.2.0/lib/uglifier.rb:195:in `run_uglifyjs'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/uglifier-3.2.0/lib/uglifier.rb:157:in `compile'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/uglifier_compressor.rb:53:in `call'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/uglifier_compressor.rb:28:in `call'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:75:in `call_processor'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `call_processors'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:60:in `block in load'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:44:in `load'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:47:in `load'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/base.rb:66:in `find_asset'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/base.rb:73:in `find_all_linked_assets'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:142:in `block in find'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:228:in `block in stat_tree'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `each'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `stat_directory'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:227:in `stat_tree'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in `each'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in `block in logical_paths'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in `each'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in `logical_paths'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:140:in `find'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:185:in `compile'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-3.7.1/lib/rake/sprocketstask.rb:147:in `with_logger'
/Users/Joseph/.rvm/gems/ruby-2.4.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
/Users/Joseph/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/application.rb:108:in `each'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/application.rb:80:in `block in run'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/lib/rake/application.rb:77:in `run'
/Users/Joseph/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/Users/Joseph/.rvm/gems/ruby-2.4.0/bin/rake:22:in `load'
/Users/Joseph/.rvm/gems/ruby-2.4.0/bin/rake:22:in `<main>'
2 个解决方案
#1
1
Turns out my JS was not perfectly clean. I had some code let parent... whereas it should have been var parent.
原来我的JS并不是很干净。我有一些代码让父母...而它应该是var父母。
Thanks for your help.
谢谢你的帮助。
#2
0
Try adding the below line to your Gemfile:
尝试将以下行添加到您的Gemfile:
group :assets do
gem 'uglifier'
end
Move that gem out of assets group
将该gem移出资产组
#1
1
Turns out my JS was not perfectly clean. I had some code let parent... whereas it should have been var parent.
原来我的JS并不是很干净。我有一些代码让父母...而它应该是var父母。
Thanks for your help.
谢谢你的帮助。
#2
0
Try adding the below line to your Gemfile:
尝试将以下行添加到您的Gemfile:
group :assets do
gem 'uglifier'
end
Move that gem out of assets group
将该gem移出资产组