2015-11-03 76 views
0

錯誤消息:ExecJS :: RuntimeError在試驗#指數Ruby on Rails的MongoDB的具有

ExecJS::RuntimeError in Tests#index Showing D:/dropWithCoffee/app/views/layouts/application.html.erb where line #6 raised: SyntaxError: [stdin]:1:1: unexpected //

我在網上嘗試以下解決方案:

First Solution:

在更改的文件

Ruby2.1.0\lib\ruby\gems\2.1.0\gems\execjs-2.6.0\lib\execjs\runtimes.rb

來自:

JScript = ExternalRuntime.new(
     name:  "JScript", 
     command:  "cscript //E:jscript //Nologo //U", 
     runner_path: ExecJS.root + "/support/jscript_runner.js", 
     encoding: ''UTF-16LE'' # CScript with //U returns UTF-16LE 
    ) 

要:

JScript = ExternalRuntime.new(
     name:  "JScript", 
     command:  "cscript //E:jscript //Nologo", 
     runner_path: ExecJS.root + "/support/jscript_runner.js", 
     encoding: 'UTF-8' # CScript with //U returns UTF-16LE 
    ) 

什麼都沒有改變:

Second Solution:

取消註釋在寶石文件中的以下行:
gem 'therubyracer', platforms: :ruby
和運行bundle。 錯誤仍然存​​在。

Third Solution:

將咖啡寶石從1.9.0更改爲1.8.0版本。
我的寶石文件中的咖啡寶石是 gem 'coffee-script-source', '1.8.0' 並運行bundle update命令。 沒有變化。

Fourth Solution:

移除了application.js。它解決了這個問題,但CoffeeScript的是不是裝上我的瀏覽器//= require_tree . 線。 以下是我的gemfile:

source 'https://rubygems.org' 


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 
gem 'rails', '4.2.4' 
# Use SCSS for stylesheets 
gem 'sass-rails', '~> 5.0' 
# Use Uglifier as compressor for JavaScript assets 
gem 'uglifier', '>= 1.3.0' 
# Use CoffeeScript for .coffee assets and views 
gem 'coffee-script-source', '1.8.0' 
# See https://github.com/rails/execjs#readme for more supported runtimes 
#gem 'therubyracer', platforms: :ruby 
gem 'jquery-ui-rails', '~> 5.0.0' 
# Use jquery as the JavaScript library 
gem 'jquery-rails' 
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks 
gem 'turbolinks' 
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 
gem 'jbuilder', '~> 2.0' 
# bundle exec rake doc:rails generates the API under doc/api. 
gem 'sdoc', '~> 0.4.0', group: :doc 
gem 'execjs' 
gem 'mongoid', '~> 5' 
gem 'bson_ext' 
# Use ActiveModel has_secure_password 
# gem 'bcrypt', '~> 3.1.7' 

# Use Unicorn as the app server 
# gem 'unicorn' 

# Use Capistrano for deployment 
# gem 'capistrano-rails', group: :development 

group :development, :test do 
    # Call 'byebug' anywhere in the code to stop execution and get a debugger console 
    gem 'byebug' 
end 

group :development do 
    # Access an IRB console on exception pages or by using <%= console %> in views 
    gem 'web-console', '~> 2.0' 
end 

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 

Rails版本:4.2.4。
Ruby版本:2.1.5p273。 操作系統:windows 7.
沒有解決方案上面的工作。

這是這個錯誤在我的開發日誌:

Started GET "/" for ::1 at 2015-11-03 12:14:37 +0530 
Processing by TestsController#index as HTML 
    Rendered tests/index.html.erb within layouts/application (79599.6ms) 
Completed 500 Internal Server Error in 84949ms 

ActionView::Template::Error (SyntaxError: [stdin]:1:1: unexpected //): 
    3: <head> 
    4: <title>DropWithCoffee</title> 
    5: <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> 
    6: <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> 
    7: <%= csrf_meta_tags %> 
    8: </head> 
    9: <body> 
    app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb__1027629002_58458144' 


    Rendered C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.2.4/lib/action_dispatch/middleware/templates/rescues/_source.erb (29.0ms) 
    Rendered C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.2.4/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (122.0ms) 
    Rendered C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.2.4/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (20.0ms) 
    Rendered C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.2.4/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb within rescues/layout (495.0ms) 
    Rendered C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/web-console-2.2.1/lib/web_console/templates/_markup.html.erb (4.0ms) 
    Rendered C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/web-console-2.2.1/lib/web_console/templates/_inner_console_markup.html.erb within layouts/inlined_string (3.0ms) 
    Rendered C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/web-console-2.2.1/lib/web_console/templates/_prompt_box_markup.html.erb within layouts/inlined_string (2.0ms) 
    Rendered C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/web-console-2.2.1/lib/web_console/templates/style.css.erb within layouts/inlined_string (2.0ms) 
    Rendered C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/web-console-2.2.1/lib/web_console/templates/console.js.erb within layouts/javascript (267.0ms) 
    Rendered C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/web-console-2.2.1/lib/web_console/templates/main.js.erb within layouts/javascript (2.0ms) 
    Rendered C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/web-console-2.2.1/lib/web_console/templates/error_page.js.erb within layouts/javascript (4.0ms) 
    Rendered C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/web-console-2.2.1/lib/web_console/templates/index.html.erb (672.0ms) 

回答

1

這是因爲小的語法error.I在日誌中發現的錯誤是因爲//在我file.It是因爲評論。 In .js。我們評論爲//。但是,在咖啡腳本中,我們將其評爲# .i將.js文件更改爲.js.coffee。但未註釋行。這導致了錯誤。如果這可能有幫助其他遇到同樣問題的人。

+0

對我來說它工作 –