[英]Ruby on Rails [heroku] git push heroku master error
我试图将我的Web应用程序上传到heroku,但是发生以下错误。
(我正在使用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.
首先,它说“在系统中没有检测到Yarn可执行文件”,但是如果我用yarn -v检查它,它将被正确下载。
另外,ExecJS :: RuntimeError:SyntaxError:意外字符'`'错误似乎是无法识别es6,作为解决方案
config.assets.js_compressor =:uglifier
config.assets.js_compressor = Uglifier.new(和声:true)
更改为似乎可以阅读es6。 但是上述错误仍然存在。
另外,如果我在控制台上运行“ rake asset:precompile RAILS_ENV = production”,则它可以正常运行而不会出错。
谢谢。
尝试将此gem添加到您的gem文件中。
gem 'therubyracer'
试试这个链接:
将Rails应用程序部署到Heroku时的语法错误:ExecJS :: RuntimeError:SyntaxError:意外字符
config.assets.js_compressor =: uglifier
=: uglifier
之间的空间:
和uglifier
?
应该是= :uglifier
并尝试使用不带字符串RAILS_ENV = production
预编译命令,因为Heroku默认安装生产模式。 如果我没错的话
尝试此操作,转到其网站上的heroku仪表板,选择您的应用,单击齿轮图标(设置),向下滚动,直到看到“ build packs”,添加ruby和nodejs buildpacks,并确保顺序是该nodejs出现首先在列表中,然后是红宝石(从上到下)。
如果那行不通,您能说明一下如何触发JS的编译吗?
说明:我之前已经看到过此错误(使用npm而不是yarn),从本质上来说,您希望herokus nodejs buildpack负责JS编译,内置的一个rails似乎与它们的系统不兼容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.