[Rails] How to solve "Uglifier :: Error: Unexpected character'`'"

Development environment

・ Ruby: 2.5.7 Rails: 5.2.4 ・ Vagrant: 2.2.7 -VirtualBox: 6.1 ・ OS: macOS Catalina

Event

The following error occurs when deploying with Capistrano

Terminal


deploy:assets:precompile
 01 $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile
 01 rake aborted!
 01 Uglifier::Error: Unexpected character '`'

Cause

It was caused by the backticks (`) of the template literal that was written in the JavaScript file.

Solution

Comment out line 27 of production.rb.

production.rb


# config.assets.js_compressor = :uglifier

Recommended Posts

[Rails] How to solve "Uglifier :: Error: Unexpected character'`'"
How to write Rails
[Rails error] unexpected tIDENTIFIER
How to uninstall Rails
[Rails] How to get success and error messages
[rails] How to post images
[Rails] How to use enum
[Rails] How to install devise
[Rails] How to use enum
How to read rails routes
How to use rails join
How to write Rails validation
[Rails] How to use validation
[Rails] How to disable turbolinks
[Rails] How to use authenticate_user!
[Rails] How to use "kaminari"
[Rails] How to implement scraping
[Rails] How to make seed
How to write Rails routing
[Rails] How to install simple_calendar
[Rails] How to install reCAPTCHA
[Rails] How to use Scope
[Rails] How to solve the error "undefined method` visit'" when using Capybara with Rspec
[Rails] How to display error messages for comment function (for beginners)
[Rails] How to use gem "devise"
How to deploy jQuery on Rails
[Rails] How to install Font Awesome
[Rails] How to use devise (Note)
[Rails] How to use flash messages
[rails] How to display db information
[Rails] How to write in Japanese
[Rails] Unexpected validation error in devise
[Rails] How to prevent screen transition
How to enclose any character with "~"
How to use Ruby on Rails
How to deploy Bootstrap on Rails
[Rails] How to speed up docker-compose
[Rails] How to add new pages
Rails on Tiles (how to write)
[Rails] How to write exception handling?
[Rails] How to install ImageMagick (RMajick)
[Rails] How to install Font Awesome
[Rails] How to use Active Storage
How to introduce jQuery in Rails 6
[Rails] How to implement star rating
How to return Rails API mode to Rails
How to get along with Rails
[Introduction to Rails] How to use render
[Rails] syntax error, unexpected tSTRING_END, expecting'''
How to install Swiper in Rails
[Rails / RSpec] How to deal with element has zero size error
[Ruby version error] How to solve Your Ruby version is ~, but your Gemfile specified ~
[Rails] How to omit the display of the character string of the link_to method
[Rails] About Uglifier :: Error: Unexpected token: at the time of deployment
How to solve the unknown error when using slf4j in Java
[Rails] PG :: DuplicateTable: ERROR: relation "users" How to resolve already exists
How to implement search functionality in Rails
How to use custom helpers in rails
[Rails] How to convert from erb to haml
[Rails] How to upload images using Carrierwave
How to put out the error bundling