简体   繁体   English

Ruby on Rails [heroku] git push heroku master错误

[英]Ruby on Rails [heroku] git push heroku master error

I am trying to upload my web app on heroku, but the following error occurs. 我试图将我的Web应用程序上传到heroku,但是发生以下错误。

(I'm coding with cloud 9 IDE) (我正在使用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. 首先,它说“在系统中没有检测到Yarn可执行文件”,但是如果我用yarn -v检查它,它将被正确下载。

Also, ExecJS :: RuntimeError: SyntaxError: Unexpected character '`' error seems to be that es6 is not recognized, as a solution 另外,ExecJS :: RuntimeError:SyntaxError:意外字符'`'错误似乎是无法识别es6,作为解决方案

config.assets.js_compressor =: uglifier config.assets.js_compressor =:uglifier

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

Changed to This seems to be able to read es6. 更改为似乎可以阅读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. 另外,如果我在控制台上运行“ rake asset:precompile RAILS_ENV = production”,则它可以正常运行而不会出错。

Thanks. 谢谢。

Try to add this gem in your gem file. 尝试将此gem添加到您的gem文件中。

gem 'therubyracer'

Try this link: 试试这个链接:

Syntax error when deploying Rails app to Heroku: ExecJS::RuntimeError: SyntaxError: Unexpected character 将Rails应用程序部署到Heroku时的语法错误:ExecJS :: RuntimeError:SyntaxError:意外字符

config.assets.js_compressor =: uglifier

=: uglifier space between : and uglifier ? =: uglifier之间的空间:uglifier

should be = :uglifier 应该是= :uglifier

and try to use precompile command without string RAILS_ENV = production because Heroku installs production mode by default. 并尝试使用不带字符串RAILS_ENV = production预编译命令,因为Heroku默认安装生产模式。 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). 尝试此操作,转到其网站上的heroku仪表板,选择您的应用,单击齿轮图标(设置),向下滚动,直到看到“ build packs”,添加ruby和nodejs buildpacks,并确保顺序是该nodejs出现首先在列表中,然后是红宝石(从上到下)。

If that doesn't work, can you clarify how you are triggering the compilation of your JS? 如果那行不通,您能说明一下如何触发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. 说明:我之前已经看到过此错误(使用npm而不是yarn),从本质上来说,您希望herokus nodejs buildpack负责JS编译,内置的一个rails似乎与它们的系统不兼容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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