简体   繁体   中英

ExecJS::RuntimeError: SyntaxError: Unexpected token: punc ()) from get@(execjs):3538:630

I have an issue when precompiling to Heroku and I checked on Stack overflow to find a debug method which is:

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

When I run rail console with this command, it gives me an error in application.js which is

app/assets/javascripts/application.js
ExecJS::RuntimeError: SyntaxError: Unexpected token: punc ())
from get@(execjs):3538:630

The following is my application.js file which i am trying to load the page when someone make a selection from subject list or enter something in the course field. The program works perfectly when running locally but fails to deploy on Heroku. Could you please tell me where I make the run toke cuz I really cannot find it.

//= require jquery3
//= require rails-ujs
//= require turbolinks
//= require_tree .
//= require tether
//= require popper
//= require bootstrap
$(document).on('turbolinks:load', () => {
  $('#course').on('input', function() {
    if (this.value.length > 1) Rails.fire($('.search-form')[0], 'submit')
  })
  $('#subject').on('change', () => Rails.fire($('.search-form')[0], 'submit'))
})

The node's version in the target machine is probably lower than your local one and does not support ES5+ js syntax. Somewhat related to that: SyntaxError: Unexpected token ) ES6 giving SyntaxError: Unexpected token )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM