0

推送到 Heroku 时遇到以下错误。前几天工作正常。我尝试推送的提交没有重大配置更改。我很困惑如何解决这个问题。Rails 5.1 应用程序使用以下构建包:

1. heroku/nodejs
2. heroku/ruby

我正在使用 webpacker 和纱线。我认为这与它有关,但难以挖掘更多信息。

remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        yarn install v0.27.5
remote:        [1/4] Resolving packages...
remote:        [2/4] Fetching packages...
remote:        warning fsevents@1.1.2: The platform "linux" is incompatible with this module.
remote:        info "fsevents@1.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
remote:        [3/4] Linking dependencies...
remote:        [4/4] Building fresh packages...
remote:        Done in 6.62s.
remote:        rake aborted!
remote:        ExecJS::RuntimeError: SyntaxError: Name expected
remote:        JS_Parse_Error.get ((execjs):3538:621)
remote:        (execjs):4060:47
remote:        (execjs):1:102
remote:        Object.<anonymous> ((execjs):1:120)
remote:        Module._compile (module.js:571:32)
remote:        Object.Module._extensions..js (module.js:580:10)
remote:        Module.load (module.js:488:32)
remote:        tryModuleLoad (module.js:447:12)
remote:        Function.Module._load (module.js:439:3)
remote:        Module.runMain (module.js:605:10)
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/execjs-2.7.0/lib/execjs/external_runtime.rb:39:in `exec'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/execjs-2.7.0/lib/execjs/external_runtime.rb:21:in `eval'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/execjs-2.7.0/lib/execjs/external_runtime.rb:46:in `call'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/uglifier-3.2.0/lib/uglifier.rb:195:in `run_uglifyjs'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/uglifier-3.2.0/lib/uglifier.rb:157:in `compile'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/uglifier_compressor.rb:53:in `call'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/uglifier_compressor.rb:28:in `call'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:75:in `call_processor'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `reverse_each'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `call_processors'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:134:in `load_from_unloaded'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:60:in `block in load'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:44:in `load'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:20:in `block in initialize'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:47:in `load'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/base.rb:66:in `find_asset'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/base.rb:73:in `find_all_linked_assets'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:142:in `block in find'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:228:in `block in stat_tree'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `each'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `stat_directory'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:227:in `stat_tree'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in `each'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in `block in logical_paths'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in `each'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in `logical_paths'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:140:in `find'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:185:in `compile'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-rails-3.2.0/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/rake/sprocketstask.rb:147:in `with_logger'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/sprockets-rails-3.2.0/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
remote:        /tmp/build_d7b1075d17c0c421422ebdbfc017919a/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
remote:        Tasks: TOP => assets:precompile
remote:        (See full trace by running task with --trace)
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected ....

经过进一步研究,发现问题与Uglifier有关。当我将第三方库 datepicker.js 的内容复制并粘贴到 Uglifier 中时,我得到了同样的错误:

> Uglifier.compile( <<< file contents >>> )
ExecJS::RuntimeError: SyntaxError: Name expected
from JS_Parse_Error.get ((execjs):3538:621)
4

2 回答 2

1

我相信问题与您服务器上的yarn安装有关linux

事实上,您可以在yarngithub 存储库中找到该文件

纱线 fsevents-1.1.2

您还可以找到类似的问题,其中纱线的 heroku 安装将失败并出现相同的错误warning fsevents@1.1.2: The platform "linux" is incompatible with this module.

错误是相同的 警告 fsevents@1.1.2:平台“linux”与此模块不兼容。info "fsevents@1.1.2" 是一个可选的依赖项和失败的兼容性检查。从安装中排除它。

Heroku 无法在 linux 平台上安装 yarn

纱线是在 Rails 5.1 中添加的,我也必须解决这个错误,我还在 SO 上打开了一个问题。

我的问题是在开发中,因为我有Linux Mint。可能在开发中安装纱线让我在生产中不会遇到问题。

仍然我在使用node.js开发时安装它时遇到问题,所以我最终使用npm命令npm install yarn -g,你可以在你的 heroku 服务器上运行它,heroku run npm install yarn -g或者你可以使用nodejs,yarn 安装指南听到了

https://yarnpkg.com/en/docs/install

这也是对非常相似的问题列表的查询,您可以阅读这些帖子并可能找到解决问题的方法。这个问题不是来自 ruby​​ on rails,而是其他使用nodejs.

在这种情况下,您还要使用 nodejs 安装 yarn,所以问题可能与 nodejs 有关

https://duckduckgo.com/?q=heroku+yarn+installation+The+platform+%22linux%22+is+incompatible&atb=v52-6_b&ia=qa

FSEvents API 说明

这似乎是 fsevents 的依赖性问题。您的操作系统 Arch Linux 不支持它。如果你前往 Strongloop 的 fsevents Github 页面,你会在他们的 README 中看到这个

在 Node.js 中对 OS X FSEvents 的本机访问 OS X 中的 FSEvents API 允许应用程序注册以获取给定目录树更改的通知。它是 kqueue 的一个非常快速和轻量级的替代品。所以,我会说这不是纱线问题。其他错误可能是先前失败的结果。

阅读更多

https://github.com/yarnpkg/yarn/issues/2142

无论如何,他们应该通过此修复解决此问题

https://github.com/yarnpkg/yarn/pull/2279

如果你不能解决这个问题,也许你可以打开一个问题

于 2017-09-18T02:08:16.887 回答
1

我发现这个问题的原因与 Uglifier 在尝试处理名为 js-datepicker (datepicker.js) 的第三方库时可能存在的错误有关。我在 Uglifier Github 上打开了一个问题:https ://github.com/lautis/uglifier/issues/124

我通过在我的 app/assets/javascripts/application.js 文件中包含缩小的 js-datepicker 找到了一个解决方法,就像这样。

//= require js-datepicker/datepicker.min
于 2017-09-18T22:46:02.080 回答