我在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 .
RAILS_ENV=production rake assets:precompile
,是否能够重现此问题?如果可以,那么很可能是您的资产管道中出现了冲突。 - Bobby Matson)
而不是}
。 - Fabrizio Bertoglio