2016-11-24 70 views
3
RAILS_ENV=production rake assets:precompile --trace 
Digest::Digest is deprecated; use Digest 
Digest::Digest is deprecated; use Digest 
** 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 operator «=», expected punc «,» (line: 159, col: 25, pos: 5132) 

Error 
    at new JS_Parse_Error (/tmp/execjs20161124-23752-1wuk17bjs:3623:11948) 
    at js_error (/tmp/execjs20161124-23752-1wuk17bjs:3623:12167) 
    at croak (/tmp/execjs20161124-23752-1wuk17bjs:3623:22038) 
    at token_error (/tmp/execjs20161124-23752-1wuk17bjs:3623:22175) 
    at expect_token (/tmp/execjs20161124-23752-1wuk17bjs:3623:22411) 
    at expect (/tmp/execjs20161124-23752-1wuk17bjs:3623:22562) 
    at ctor.argnames (/tmp/execjs20161124-23752-1wuk17bjs:3623:27486) 
    at function_ (/tmp/execjs20161124-23752-1wuk17bjs:3623:27550) 
    at /tmp/execjs20161124-23752-1wuk17bjs:3623:24469 
    at /tmp/execjs20161124-23752-1wuk17bjs:3623:22954 
new JS_Parse_Error ((execjs):3623:11948) 
js_error ((execjs):3623:12167) 
croak ((execjs):3623:22038) 
token_error ((execjs):3623:22175) 
expect_token ((execjs):3623:22411) 
expect ((execjs):3623:22562) 
ctor.argnames ((execjs):3623:27486) 
function_ ((execjs):3623:27550) 
(execjs):3623:24469 
(execjs):3623:22954 
/usr/local/rvm/gems/ruby-2.3.1/gems/execjs-2.7.0/lib/execjs/external_runtime.rb:39:in `exec' 
/usr/local/rvm/gems/ruby-2.3.1/gems/execjs-2.7.0/lib/execjs/external_runtime.rb:21:in `eval' 
/usr/local/rvm/gems/ruby-2.3.1/gems/execjs-2.7.0/lib/execjs/external_runtime.rb:46:in `call' 
/usr/local/rvm/gems/ruby-2.3.1/gems/uglifier-3.0.3/lib/uglifier.rb:182:in `run_uglifyjs' 
/usr/local/rvm/gems/ruby-2.3.1/gems/uglifier-3.0.3/lib/uglifier.rb:144:in `compile' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/uglifier_compressor.rb:52:in `call' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/uglifier_compressor.rb:28:in `call' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/processor_utils.rb:75:in `call_processor' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/processor_utils.rb:57:in `block in call_processors' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/processor_utils.rb:56:in `reverse_each' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/processor_utils.rb:56:in `call_processors' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/loader.rb:134:in `load_from_unloaded' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/loader.rb:60:in `block in load' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/loader.rb:44:in `load' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/cached_environment.rb:20:in `block in initialize' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/cached_environment.rb:47:in `load' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/base.rb:66:in `find_asset' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/base.rb:73:in `find_all_linked_assets' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/manifest.rb:142:in `block in find' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/path_utils.rb:228:in `block in stat_tree' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/path_utils.rb:212:in `block in stat_directory' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/path_utils.rb:209:in `each' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/path_utils.rb:209:in `stat_directory' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/path_utils.rb:227:in `stat_tree' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/path_utils.rb:231:in `block in stat_tree' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/path_utils.rb:212:in `block in stat_directory' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/path_utils.rb:209:in `each' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/path_utils.rb:209:in `stat_directory' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/path_utils.rb:227:in `stat_tree' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/legacy.rb:105:in `each' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/legacy.rb:105:in `block in logical_paths' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/legacy.rb:104:in `each' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/legacy.rb:104:in `logical_paths' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/manifest.rb:140:in `find' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/manifest.rb:185:in `compile' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-rails-3.2.0/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/rake/sprocketstask.rb:147:in `with_logger' 
/usr/local/rvm/gems/ruby-2.3.1/gems/sprockets-rails-3.2.0/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define' 
/usr/local/rvm/gems/ruby-2.3.1/gems/rake-11.3.0/lib/rake/task.rb:248:in `block in execute' 
/usr/local/rvm/gems/ruby-2.3.1/gems/rake-11.3.0/lib/rake/task.rb:243:in `each' 
/usr/local/rvm/gems/ruby-2.3.1/gems/rake-11.3.0/lib/rake/task.rb:243:in `execute' 
/usr/local/rvm/gems/ruby-2.3.1/gems/rake-11.3.0/lib/rake/task.rb:187:in `block in invoke_with_call_chain' 
/usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize' 
/usr/local/rvm/gems/ruby-2.3.1/gems/rake-11.3.0/lib/rake/task.rb:180:in `invoke_with_call_chain' 
/usr/local/rvm/gems/ruby-2.3.1/gems/rake-11.3.0/lib/rake/task.rb:173:in `invoke' 
/usr/local/rvm/gems/ruby-2.3.1/gems/rake-11.3.0/lib/rake/application.rb:152:in `invoke_task' 
/usr/local/rvm/gems/ruby-2.3.1/gems/rake-11.3.0/lib/rake/application.rb:108:in `block (2 levels) in top_level' 
/usr/local/rvm/gems/ruby-2.3.1/gems/rake-11.3.0/lib/rake/application.rb:108:in `each' 
/usr/local/rvm/gems/ruby-2.3.1/gems/rake-11.3.0/lib/rake/application.rb:108:in `block in top_level' 
/usr/local/rvm/gems/ruby-2.3.1/gems/rake-11.3.0/lib/rake/application.rb:117:in `run_with_threads' 
/usr/local/rvm/gems/ruby-2.3.1/gems/rake-11.3.0/lib/rake/application.rb:102:in `top_level' 
/usr/local/rvm/gems/ruby-2.3.1/gems/rake-11.3.0/lib/rake/application.rb:80:in `block in run' 
/usr/local/rvm/gems/ruby-2.3.1/gems/rake-11.3.0/lib/rake/application.rb:178:in `standard_exception_handling' 
/usr/local/rvm/gems/ruby-2.3.1/gems/rake-11.3.0/lib/rake/application.rb:77:in `run' 
/usr/local/rvm/gems/ruby-2.3.1/gems/rake-11.3.0/exe/rake:27:in `<top (required)>' 
/usr/local/rvm/gems/ruby-2.3.1/bin/rake:23:in `load' 
/usr/local/rvm/gems/ruby-2.3.1/bin/rake:23:in `<main>' 
/usr/local/rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `eval' 
/usr/local/rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `<main>' 
Tasks: TOP => assets:precompile 

發生上述錯誤並中止資產創建。有關如何繞過它的任何幫助,因爲生產中的Ajax文件不起作用。ExecJS :: RuntimeError:SyntaxError:意外的標記運算符

+0

嘗試運行RAILS_ENV =生產耙資產:預編譯--trace,更多錯誤日誌 – user100693

+0

@ user100693更新它 –

+0

@HarshaMV check [this](http://stackoverflow.com/questions/30422437/execjsprogramerror-unexpected-token-punc-expected-punc-when-running) –

回答

1

我知道這是老了,但我得到了同樣的錯誤,我來到這裏,從谷歌,所以萬一有人確實太少,這是我的解決方案:

我用這個控制檯來查找文件和錯誤的行(把它從this answer):

JS_PATH = "app/assets/javascripts/**/*.js"; 
Dir[JS_PATH].each do |file_name| 
    puts "\n#{file_name}" 
    puts Uglifier.compile(File.read(file_name)) 
end 

我的錯誤是,我用的是新ES6 JavaScript語法,不符合我的資產預編譯兼容。在特定的,定義默認參數的函數定義,所以我把該解決方案從this answer

相反的:

function foo(a, b = default_b) { 
    ... 
} 

用途:

function foo(a, b) { 
    b = typeof b !== 'undefined' ? b : 'default_b'; 
    ... 
}