如何修复 Rails RuntimeError 当前 ExectJ 不支持 ES5?

How do I fix Rails RuntimeError Current ExectJ doesn't support ES5?

当我在课程结束时去更新页面 "localhost: 3000" 时,我看到了我所附图片中发生的事情。如果我卸载 "node.js","localhost: 3000" 将不再工作,即它会给我这个错误 "We're sorry, but something went wrong.If you are the application owner check the logs for more information." 为什么?

主要问题出在您的 Gemfile 中

gem 'therubyracer', platforms: :ruby
gem 'mini_racer', platforms: :ruby

您有两个赛车类型 gems,您只需要一个。

您应该只使用 gem 'mini_racer' 并删除 therubyracer。这样做 运行 bundle install。您还需要清理留在 routes.rb 文件中的合并冲突内容。在 bundle install 之前做到这一点,你应该会很好。

您可能也不需要锁定您的 gem 版本,直到您拥有更发达和稳定的堆栈。您最好尽早升级所有内容,因为您的某些版本已经过时了。要升级您的 gem,只需删除每个 gem 行之后的所有版本内容,即

gem 'coffee-rails', '~> 4.2' 

可以是

gem 'coffee-rails'

全部删除后,运行

bundle update

这是一个 patchfile,它会在您遇到问题时执行这些操作。您可以将其保存在本地,然后如果您愿意,可以只保存 运行 git apply fix_gem_dependancies.patch

更新最后一个:这是我为此做的最后一件事。摆脱你不需要的 gems,只需使用这个 Gemfile

source 'https://rubygems.org'

gem 'rails', '~> 5.1.3'
gem 'sqlite3'
gem 'puma', '~> 3.7'
gem 'sass-rails'
gem 'uglifier'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder'
gem 'sdoc'

gem 'autoprefixer-rails'

gem 'execjs'

gem 'materialize-sass'


group :development, :test do
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'capybara', '~> 2.13'
  gem 'selenium-webdriver'
end

group :development do
  gem 'web-console', '>= 3.3.0'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

我发给你的补丁应该已经修复了路由,但你显然不知道你在用 git 做什么。这是你的 routes.rb 文件

Rails.application.routes.draw do

  root 'pages#home'

  get 'about' => 'pages#about'

  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end