简体   繁体   中英

Ruby on Rails [heroku] git push heroku master error

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.

Try to add this gem in your gem file.

gem 'therubyracer'

Try this link:

Syntax error when deploying Rails app to Heroku: ExecJS::RuntimeError: SyntaxError: Unexpected character

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM