首页 > 解决方案 > Ruby on Rails [heroku] git push heroku master 错误

问题描述

我正在尝试在 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: Unexpected character '`' error 好像是es6无法识别,作为解决方法

config.assets.js_compressor =: uglifier

config.assets.js_compressor = Uglifier.new(和谐:真)

改成this好像能读es6了。但上述错误仍然存​​在。

此外,如果我在控制台上运行“rake assets: precompile RAILS_ENV = production”,它会正常运行而不会出错。

谢谢。

标签: ruby-on-railsrubyherokuruby-on-rails-5

解决方案


尝试将此 gem 添加到您的 gem 文件中。

gem 'therubyracer'

试试这个链接:

将 Rails 应用程序部署到 Heroku 时出现语法错误:ExecJS::RuntimeError: SyntaxError: Unexpected character


推荐阅读