ruby-on-rails - 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”,它会正常运行而不会出错。
谢谢。
解决方案
尝试将此 gem 添加到您的 gem 文件中。
gem 'therubyracer'
试试这个链接:
将 Rails 应用程序部署到 Heroku 时出现语法错误:ExecJS::RuntimeError: SyntaxError: Unexpected character
推荐阅读
- image-processing - Keras ImageDataGenerator 可以在 -1 和 1 之间重新缩放图像吗
- r - 如何使用R检查文件中单词列表的字符串
- android - 浏览器覆盖遮挡页面底部
- java - 如何突出显示 javafx Textarea 中的文本?
- python - 如何连续多次从列表中生成随机项目,但每次生成不同的项目
- node.js - Redis 按模式删除
- excel - 使用条件从excel中的字符串中提取数字
- node.js - Dropzone / React / NodeJS - 上传图像数组
- perl - CORE Perl 中的哪些内容将 ERRNO ($!) 设置为成功?
- c++ - 我在 CodeBlocks 上遇到了这个错误,但如果我修复它,它会触发一个错误,该错误是从修复第一个错误时触发的。我该如何解决?