[RUBY] [Heroku] How to solve when an error is displayed on git push heroku master

I got some errors when deploying Heroku I hope it helps the solution.

Development environment

ruby 2.5.7 Rails 5.2.4.3 OS: macOS Catalina

flow

1 Check the error in the terminal 2 Log in to my page on heroku 3 Examine the error location 4 Clear the error

Log in to heroku's My Page

https://dashboard.heroku.com/apps Please log in here. At first, a confirmation screen will appear, but you can accept it as it is. (Please translate and check just in case)

After logging in, there is a link for the created app name, so click it and There is "Latest activity" on the right side, If you see a deployment error below it, The X mark is in red.

If you jump to the "View build log" next to it, you will find a detailed error.

The error that actually occurred is described below, so I hope you can refer to it.

Precompiling assets failed.

Check for errors in the terminal

Terminal


remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.

Log in to heroku's My Page and check for errors

It's in the middle of the log, so look for the Error character.

heroku/ViewBuildLog


...

Uglifier::Error: Unexpected token: name (mapping). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true).
       --
       
        ...
       
        18254 
        18255 
        18256 
        18257 
        18258 function initMap(){
           =>   let mapping
       
...

Clear the error

In this case, the description of let uses ES6 syntax and an error occurred. The solution is ①

config/environments/production.rb


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

app/aseets/application.js


function initMap(){
  let mapping
↓
function initMap(){
  var mapping

In my case, I tried ①, but I couldn't solve the error, so I solved it in ②.

Summary

Of course, most errors can be resolved by searching for the wording of the error as it is. However, if the situation is different for each individual, it may not be possible to deal with it with the same solution. I think it is important to know the various solutions. I hope you find it helpful.

Also, on twitter, technologies and ideas that have not been uploaded to Qiita are also uploaded, so I would be grateful if you could follow me. Click here for details https://twitter.com/japwork

Recommended Posts

[Heroku] How to solve when an error is displayed on git push heroku master
Error when running git push heroku master on Heroku
How to resolve errors when doing git push heroku master
How to publish an application on Heroku
When deploying to Heroku, OpenApp causes an error
[Introduction] A collection of carefully selected links from how to get started on GitHub to how to solve errors when you encounter an error on Git.
How to deploy on heroku
[Ruby version error] How to solve Your Ruby version is ~, but your Gemfile specified ~
How to output the value when there is an array in the array
How to solve the unknown error when using slf4j in Java
How to redo a deployment on Heroku
[JavaScript] How to display an alert when there is an input form omission
Error when trying to use heroku command
What to do and how to install when an error occurs in DXRuby 1.4.7
How the website is displayed on the screen
[Docker] How to build when the source code is bind-mounted on the container
What to do if you get an error when you hit Heroku logs
How to send push notifications on AWS
Possibility when deploying to EC2 but nothing is displayed in the error log
How to redirect to http-> https when SSL is enabled in Rails × Heroku environment
[Ruby] Meaning of &. How to avoid the error when the receiver (object) is nil
What to do if you get an error on heroku rake db: migrate
[Ruby on Rails] How to display error messages
Note how to rollback Mysql deployed on Heroku
[Rails MySQL] How to reset DB on heroku
[Rails] How to solve "Uglifier :: Error: Unexpected character'`'"
How to solve an Expression Problem in Java
How to post images on Heroku + CarrierWave + S3
After installing'devise''bootstrap' of gemfile with rails, what to do when url is an error
[Ruby on rails] When executing the heroku command, bash: heroku: command not found is displayed. [Rails tutorial]
[Rails] How to solve the error "undefined method` visit'" when using Capybara with Rspec
How to install Ruby on an EC2 instance on AWS
How to push an app developed with Rails to Github
No error message is displayed when create action fails
How to connect to ClearDB from Sequel Pro on Heroku
[Ruby On Rails] How to reset DB in Heroku
[swift5] How to execute processing when tabBar is tapped
Null value is entered when assigning to an array
BasicDataSourceFactory is ClassNotFoundException when connecting to DB on Tomcat 8
I found no way to get the error code when I received an exception on Android
Error resolution on Heroku
How to deploy a simple Java Servlet app on Heroku
When an error occurs even though validation is not set
How to resolve Missing Template error when implementing comment function
How to specify db when creating an app with rails
An error occurs when codedeploy-agent is installed in Ubuntu Server 20.04
What is an immutable object? [Explanation of how to make]
How to check the database of apps deployed on Heroku
I want to make the frame of the text box red when there is an input error