Heroku push – ExecJS :: RuntimeError:SyntaxError:期望的名称

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

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. ((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 `' 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( <<>> ) ExecJS::RuntimeError: SyntaxError: Name expected from JS_Parse_Error.get ((execjs):3538:621) 

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

实际上你可以在yarn github存储库中找到该文件

纱线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平台上安装纱线

在Rails 5.1中添加了Yarn,我也不得不解决这个错误,我也在SO上打开了一个问题。

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

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

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

这也是一个非常相似的问题列表的查询,您可以阅读这些post,并可能找到您的问题的解决方案。 这个问题不是来自ruby on rails,而是来自使用nodejs其他框架。

在这种情况下,您还使用nodejs安装纱线,所以可能问题与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页面,你会在他们的自述文件中看到这一点

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

阅读更多内容

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

无论如何,他们应该用这个修复解决了这个问题

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

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

我发现此问题的原因与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