gpt4 book ai didi

ruby-on-rails - 部署到 Heroku:ExecJS::RuntimeError: SyntaxError: Unexpected token

转载 作者:行者123 更新时间:2023-12-04 06:24:31 27 4
gpt4 key购买 nike

我在 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 文件或任何东西。本质上,它是一个具有静态页面 Controller 的 Rails 应用程序。我什至不知道从哪里开始寻找问题。在类似的 post 上,有人提到他们删除了 uglifier gem。这根本没有改变我的结果。

欢迎提出任何建议,但请理解我实际上什么都不知道:我需要基本的分步说明,就好像我是一个 4 岁的 child 一样。此外,我确实有一个出于沮丧而产生的愚蠢问题:为什么它不给我一个错误,该错误实际上指向 生成的代码中的某些特定内容,而不是所有这些看似自动生成的垃圾?

提前致谢。

gem 文件:

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]

应用程序.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 .

最佳答案

最终为我解决了这个问题(至少这一次)是:

  1. 在本地预编译 Assets (rake assets:precompile)。这在本地系统上创建了两个文件——认为它们是 gz 文件)。
  2. 提交并推送到 Heroku。在此之后它起作用了。

虽然,这对我来说没有任何解释。我以前从来不需要预编译 Assets 。而且,如果有必要这样做,为什么 localhost 总是在不执行此命令的情况下工作?而且,Heroku 总是尝试预编译 Assets 。为什么当我推送预编译 Assets 时它会成功?反正它不重做预编译吗?

那么,目前,问题已经解决了。我不知道为什么。

关于ruby-on-rails - 部署到 Heroku:ExecJS::RuntimeError: SyntaxError: Unexpected token,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42738973/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com