0
votes

I am trying to upload my web app on heroku, but the following error occurs.

(I'm coding with cloud 9 IDE)

$ git push heroku master
.....
remote: -----> Installing node-v10.14.1-linux-x64
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        Yarn executable was not detected in the system.
remote:        Download Yarn at https://yarnpkg.com/en/docs/install
remote:        I, [2019-05-22T02:13:47.373334 #1766]  INFO -- : Writing 
/tmp/build_fcc84922ee6a02bfc05a163c871d0548/public/assets/noimage- 
3aa3997354b4e9c37f379deb61626f55ade493078d1b42dcefe4a3ccbed34106.jpg
remote:        rake aborted!
remote:        ExecJS::RuntimeError: SyntaxError: Unexpected character '`'
remote:        JS_Parse_Error.get ((execjs):3538:621)
remote:        (execjs):4060:48
remote:        (execjs):1:102
.....
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.

First of all, It says that "there Yarn executable was not detected in the system", but it is properly downloaded if I check it with yarn -v.

Also, ExecJS :: RuntimeError: SyntaxError: Unexpected character '`' error seems to be that es6 is not recognized, as a solution

config.assets.js_compressor =: uglifier

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

Changed to This seems to be able to read es6. But the above error still persists.

Also, if I run 'rake assets: precompile RAILS_ENV = production' on the console, it runs normally without error.

Thanks.

3
are you checking withheroku run yarn -v?max pleaner
@maxpleaner Thanks for your comment. It shows Running yarn -v on ⬢ myapp... up, run.1301 (Free) bash: yarn: command not found. So it means there is no yarn on heroku? how do I download yarn in heroku?kametyou777

3 Answers

0
votes

config.assets.js_compressor =: uglifier

=: uglifier space between : and uglifier?

should be = :uglifier

and try to use precompile command without string RAILS_ENV = production because Heroku installs production mode by default. if I'm not mistaken

0
votes

Try this, Go to heroku dashboard on their website, select your app, click on the gear icon (the settings), scroll down until you see “build packs” add ruby and nodejs buildpacks, and make sure the order is that that nodejs comes first in the list, and then ruby (from top to bottom).

If that doesn’t work, can you clarify how you are triggering the compilation of your JS?

Explanation: I’ve seen this error before(with npm, not yarn), essentially you want herokus nodejs buildpack to take care of JS compiling, the one rails has built in seems to not be compatible with their system.