Execjs::Runtimeerror: Syntaxerror: Unexpected Token: Operator (>) (Line: 22342, Col: 24, Pos: 826182)

ExecJS::RuntimeError: SyntaxError: Unexpected token: name (catch) (line: 41, col: 8, pos: 1392)

Syntax error with two dots. The line break sometimes makes it hard to notice.

 event.respondWith(
fetch(request). // Dot here and then...
.catch(function fallback() { // ... the one at beginning of line as well causes the issue...
caches.match(request).then(function(response) { // then, the cache
response || caches.match("/offline.html.erb"); // then, /offline cache
})
})
);

Should be

 event.respondWith(
fetch(request) // remove dot
.catch(function fallback() {
caches.match(request).then(function(response) { // then, the cache
response || caches.match("/offline.html.erb"); // then, /offline cache
})
})
);

ExecJS::RuntimeError: SyntaxError: Unexpected token operator

I know this is old, but I got the same error and I came here from Google, so in case someone does too, this was my solution:

I used this in the console to find the file and the line of the error (took it from 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

My error was that I was using the new ES6 javascript syntax, not compatible with my asset pre-compilation. In specific, defining default parameters in function definition, so I took the solution from this answer:

Instead of:

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

Use:

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

ExecJS Unexpected token: operator () in vue.js method

Well, for those who'll have the same issue, this is were my problem was, it should be .then(function(response) { instead of .then((response) => {

  fetchStates: function () {
this.$http.get('/api/locations/all_states').then(function(response) {
states = $.parseJSON(response.responseText).states
paymentInfo.$set('states', states)
}).then(function() {
$('.cs-select').trigger('chosen:updated')
})
},

Rails 5 Heroku deploy error: ExecJS::ProgramError: SyntaxError: Unexpected token: name (autoRegisterNamespace)

It may have something to do with javascript/coffescript syntax. Check if you have let, it shout be replaced with var.

Edit - see @Guilherme Lages Santos's response. Uglifier added ES6 support since version 3.2.0 so you can just use it like this in your environment file

config.assets.js_compressor = Uglifier.new(harmony: true)


Related Topics



Leave a reply



Submit