= javascript_include_tag "application"给出错误 ExecJS::运行时错误在 / 语法错误: [stdin]:1:1:意外 //=



我更像是一名Java程序员,对开发还是有点陌生(两年左右,可以编写Java代码和web应用程序),但我工作的公司有4个Rails应用程序,并被要求让这个名为CtrlPanel的应用程序工作。我一直在学习RubyonRails,以帮助解决这个应用程序的问题并使其正常工作。

我已经为这个问题工作了一个多星期,每天整天,我所做的就是解决它

我修复了一切,直到应用程序出现,web服务器运行为页面提供服务,但只要存在这个应用程序.html.haml文件,所有视图都是白色屏幕。我用非常基本的引导程序重新编写了这个文件,它有点工作,但看起来什么都不对。这个问题似乎源于一个简单的例子:=javascript_include_tag;应用程序";

当我读到Windows在更新的rails和该文件中出现问题时,我已经在互联网上尝试了从将coffee脚本源更改为v1.8.0的每一种修复方法,我已经尝试了将其从应用程序更改为默认文件的每一个变体,以及无论我做什么,你都能想到的每种类型的结尾,它都会给我这个错误消息,我似乎找不到。

我甚至不确定这句话的作用,我认为它与新的谷歌地图API有关,我验证了密钥的有效性,它以前也有效。

这是一个错误,它给出的是"=javascript_include_tag"quot;应用程序";给出错误ExecJS::RuntimeError at/SyntaxError:[stdin]:1:1:意外//=

我在Windows 10 20H2 x64 UEFI上运行电脑ruby 2.7.2p137(2020-10-01修订版5445e04352)[x64-ming32]轨道6.1.3

(我也在另一台机器上安装了Ubuntu,它给出了完全相同的错误,在另一个Windows机器上也给出了相同的错误)

如果我删除";application.html.haml";文件并放入一个骨架基本版本中,所有其他视图都开始工作,但当然没有一个看起来正确,没有菜单,没有引导程序,什么都没有
这是application.html.haml文件。

!!!
%html
%head
%title= full_title(yield(:title))
= stylesheet_link_tag    "application", media: "all"
= stylesheet_link_tag    "print", media: "print"
= javascript_include_tag "http://maps.googleapis.com/maps/api/js?key=AIzaSyDOejvFkvPN_KP_9gnjH-Z8PB4eLtdju4E&libraries=geometry"
= javascript_include_tag "application"
= javascript_include_tag "//www.google.com/jsapi", "chartkick"
= javascript_include_tag "http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"
= csrf_meta_tags
= render 'layouts/shim'
%meta{:content => "width=device-width, initial-scale=1.0", :name => "viewport"}
%body
= render 'layouts/header'
.container-fluid.round.master
- flash.each do |key, value|
.alert-container
.span6.offset3.alert-message.center{:class => "alert alert-#{key}"}
= value
%button.close#close-alert{"aria-hidden" => "true", "data-dismiss" => "modal", :type => "button"} ×
= yield
.spacer{style: "width:100%;margin-bottom:80px;"}
//      = render 'layouts/footer'

这是我的gemfile:

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.7.2'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
gem 'rails', '~> 6.1.3'
gem 'pg', '~> 1.1'
#gem 'postgres_ext'  Breaks the app
gem 'paperclip'
#gem 'paperclip-aws'
#gem 'aws-sdk-v1'
gem 'haml'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'sass-rails', '>= 6'
gem 'bootstrap-will_paginate'
#gem 'bootstrap'
gem 'coffee-script-source', '1.8.0'
gem 'coffee-rails'
gem 'uglifier'
gem 'by_star'
gem 'simple_enum'
gem 'jquery-turbolinks'
# data dump
#gem 'yaml_db' - Gem is no longer supported and will NOT work with Rails 6 PERIOD.
# gem 'rb-readline'
# geocoding/addressing
gem 'geocoder'
gem 'gmaps4rails'
gem 'gmaps-autocomplete-rails'
gem 'mechanize'
gem 'nikkou'
# caching
#gem 'memcachier'
#gem 'dalli'
#gem 'multi_fetch_fragments'
#gem 'cache_digests'
# Style and Appearance
gem 'will_paginate'
gem 'chartkick'
#Forms and Input
gem 'simple_form'
gem 'ransack'
#gem 'protected_attributes' - No longer works with newer Rails Versions.
gem 'chronic'
gem 'protected_attributes_continued'
gem 'chosen-rails'
# Web Scraping
gem 'nokogiri'
# PDF Conversion
gem 'wicked_pdf'
#gem 'squeel', :git => "git://github.com/activerecord-hackery/squeel.git"
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
#gem 'unicorn'
gem 'puma'
# User Management
gem 'devise'
gem 'cancan'
gem 'devise_invitable'
gem 'paper_trail'
# Content Control
gem 'browser'
# pdf creation
gem 'prawn'
gem 'prawn-rails'
gem 'combine_pdf'
gem 'pry-byebug'
#Additional Gems required by Rails 6
gem 'webpacker', '~> 5.0'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.7'
gem 'bootsnap', '>= 1.4.4', require: false

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'annotate'
gem 'better_errors'
gem 'binding_of_caller'
gem 'letter_opener'
#gem 'meta_request'
#gem 'thin'
gem 'spring'
gem 'erb2haml'
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 4.1.0'
# Display performance information such as SQL time and flame graphs for each request in your browser.
# Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
gem 'rack-mini-profiler', '~> 2.0'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 3.26'
gem 'selenium-webdriver'
# Easy installation and use of web drivers to run system tests with browsers
gem 'webdrivers'
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 vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// 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 vendor/assets/javascripts of plugins, if any, 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
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//= require jquery-ui
//= require gmaps-auto-complete
//= require timeago
//= require jquery.dataTables.min
//= require jquery.mark.min
//= require datatables.mark.min
//= require animate_numbers
//= require underscore-min
//= require gmaps/google
//= require chosen-jquery
//= require dealerships
//= require global
//= require_self
//= require_tree .

错误消息的屏幕截图:指向包含标记应用程序时出错。

我也尝试过去除";require_tree"。以及该文件中每隔一行的某个点,它似乎什么都没有改变。我已经尝试过将应用程序单词更改为默认值的每一个版本,但似乎都不起作用。

如果有人需要看其他东西,请告诉我,我是Ruby和Rails的新手,我确信这是我缺少的东西——我只是不知道是什么,文档似乎也没有帮助。

任何帮助都将不胜感激,非常感谢。Scott

我终于弄清楚了这是什么
rails的旧版本在本例v4.2.1中使用javascript_include_tag作为处理应用程序的行:

=javascript_include_tag"应用程序";

在我的例子v6.1.3.1中的rails的较新版本中,您必须使用javascript_pack_tag

=javascript_pack_tag

这解决了问题,所有的观点都开始发挥作用。我在上面确实提到过,我正在一台运行Rails v6.1.3的PC上工作;然而,我注意到我没有明确表示,我还必须将这个程序从Ruby v2.2.2和Rails v4.2.1升级到Ruby v2.7.2和Rails v6.1.3,这可能有助于更清楚地说明这一点。如果这让任何人感到困惑,我深表歉意。我对Rails和StackOverflow.com还很陌生。我很高兴地报告,这个程序只剩下一个问题,其余的程序都能正常工作。事实上,我将发布另一个问题,因为上一个问题处理的是一个复杂的范围查询,由于rails的更新版本,它再次使用了不同的语法,我还没能弄清楚。在任何情况下,即使你运行的是旧版本的Rails,并且你试图让程序在新版本上运行(我的情况是,我无法让Rails v4.2在任何东西、PC、Linux上运行或工作),你也必须将include_tag更改为pack_tag。我没有假装说我完全理解为什么。我知道这与webpacker有关,但除此之外,我仍在学习Rails。也许比我更了解语法变化的原因。哦,此外,这行最后需要阅读如下:

=javascript_pack_tag";"应用程序"数据涡轮链接跟踪":"重新加载";

我也没有涡轮链接的参考资料。

我希望这能帮助其他和我处境相似的人,这并不容易找到。当我浏览了一些关于制作其他通用应用程序的教程,并看到了这一行的区别时,我才发现了这一点。

相关内容

  • 没有找到相关文章

最新更新