我在Stackoverflow中看到了一个类似的post但有类似的错误,但据我所知,它没有解决,而且它和我的问题之间似乎存在一些差异。
一切(当然)在当地都很完美。然而,当推到Heroku时,我得到了这种疯狂:
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote: Running: rake assets:precompile
remote: rake aborted!
remote: ExecJS::RuntimeError: SyntaxError: Unexpected token punc «{», expected punc «(»
remote: JS_Parse_Error.Object.defineProperty.get ((execjs):3538:621)
remote: (execjs):4060:47
remote: (execjs):1:102
remote: Object.<anonymous> ((execjs):1:120)
remote: Module._compile (module.js:456:26)
remote: Object.Module._extensions..js (module.js:474:10)
remote: Module.load (module.js:356:32)
remote: Function.Module._load (module.js:312:12)
remote: Function.Module.runMain (module.js:497:10)
remote: startup (node.js:119:16)
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/execjs-2.7.0/lib/execjs/external_runtime.rb:39:in `exec'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/execjs-2.7.0/lib/execjs/external_runtime.rb:21:in `eval'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/execjs-2.7.0/lib/execjs/external_runtime.rb:46:in `call'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/uglifier-3.1.6/lib/uglifier.rb:190:in `run_uglifyjs'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/uglifier-3.1.6/lib/uglifier.rb:152:in `compile'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/uglifier_compressor.rb:53:in `call'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/uglifier_compressor.rb:28:in `call'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:75:in `call_processor'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `reverse_each'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `call_processors'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:134:in `load_from_unloaded'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:60:in `block in load'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:44:in `load'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:20:in `block in initialize'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:47:in `yield'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:47:in `load'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/base.rb:66:in `find_asset'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/base.rb:73:in `find_all_linked_assets'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:142:in `block in find'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:228:in `block in stat_tree'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `each'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `stat_directory'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:227:in `stat_tree'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in `each'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in `block in logical_paths'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in `each'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in `logical_paths'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:140:in `find'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:185:in `compile'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-rails-3.2.0/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/rake/sprocketstask.rb:147:in `with_logger'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-rails-3.2.0/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
remote: /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.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
它一直在继续。我在这里不认识任何事。我的项目非常基础 - 它没有自定义的.js文件或任何东西。从本质上讲,它是一个具有静态页面控制器的rails应用程序。我甚至不知道从哪里开始寻找问题。在一个类似的post上,有人提到他们删除了uglifier gem。这根本不会改变我的结果。
任何建议都值得赞赏,但请理解我确实一无所知:我需要基本的逐步说明,就好像我是一个4岁的孩子一样。另外,我确实有一个愚蠢的问题源于挫折:为什么它不会给我一个错误,实际上指向我生成的代码中的某些内容而不是所有这些看似自动生成的垃圾?
提前致谢。
的Gemfile:
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
gem 'rails', '~> 5.0.1'
gem 'bcrypt', '3.1.11'
gem 'faker', '1.6.6'
gem 'carrierwave', '~> 1.0'
gem 'mini_magick'
gem 'fog'
gem 'will_paginate', '3.1.0'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'bootstrap-sass', '3.3.6'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'jquery-rails'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'puma'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'sqlite3'
gem 'byebug', platform: :mri
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '~> 3.0.5'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
gem 'rails-controller-testing', '0.1.1'
gem 'minitest-reporters', '1.1.9'
gem 'guard', '2.13.0'
gem 'guard-minitest', '2.4.4'
end
group :production do
gem 'pg'
gem 'rails_12factor', '0.0.2'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
的application.js:
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
答案 0 :(得分:3)
最终为我解决这个问题(这次至少),是:
虽然,这对我没有任何解释。我以前从未需要预先编译资产。并且,如果有必要这样做,为什么localhost总是在不执行此命令的情况下工作?而且,Heroku总是试图预编译资产。当我推测预编译资产时,为什么它会成功?它还没有重做预编译吗?
所以,目前,问题已经解决了。我不明白为什么。