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
How to Delete a Range of Values from an Array
How to Make Xcode Use the Correct Version of Ruby When Running a Script
Split Seeds.Rb into Multiple Sections
How to Use Regex for Utf8 in Ruby
Ssl_Connect Syscall Returned=5 Errno=0 State=Sslv2/V3 Read Server Hello A
Ruby: Yield Block from a Block
Create a Human-Readable List with "And" Inserted Before the Last Element from a Ruby List
Openssl Trouble with Ruby 1.9.3
How to Integrate 'Premailer' with Rails
Ruby on Rails Map.Root Doesn't Seem to Be Working
Catching Timeout Errors with Ruby Mechanize
Spacing Around Parentheses in Ruby
Parsing Large Xml Files W/ Ruby & Nokogiri
Ruby Errors with Os X Yosemite
Execjs::Programerror in Welcome#Index Typeerror: Object Doesn't Support This Property or Method
Rake Db:Migrate Is Being Aborted Due to Rake Version Difference