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

时间:2017-09-18 01:44:54

标签: ruby-on-rails node.js heroku yarnpkg uglifier

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

1. heroku/nodejs
2. heroku/ruby

我正在使用网络包装机和纱线。我认为这与它有关,但无法挖掘更多信息。

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)

2 个答案:

答案 0 :(得分:1)

我认为问题与yarn服务器

上的linux安装有关

实际上,您可以在yarn github存储库

中找到该文件

Yarn 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 fails to install yarn on linux platform

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

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

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

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

这也是一个非常相似的问题列表的查询,您可以阅读这些帖子,并可能找到您的问题的解决方案。这个问题不是来自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页面,你会在他们的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

如果你无法解决这个问题,也许你可以解决问题

答案 1 :(得分: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