我使用控制器生成了一个页面。但是当我去 localhost:3000/pages/home. 我收到此错误:Pages#home 中的 ExecJS::RuntimeError
@RyanBigg 好的,这是完整的错误代码:
ExecJS::RuntimeError in Pages#home
Showing C:/Users/Anishka/Desktop/test/myfirstapp/app/views/layouts/application.html.erb where line #6 raised:
(in C:/Users/Anishka/Desktop/test/myfirstapp/app/assets/javascripts/pages.js.coffee)
Extracted source (around line #6):
3: <head>
4: <title>Myfirstapp</title>
5: <%= stylesheet_link_tag "application", :media => "all" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8: </head>
9: <body>
Rails.root: C:/Users/Anishka/Desktop/test/myfirstapp
Application Trace | Framework Trace | Full Trace
app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb__601430158_32305500'
Request
Parameters:
None
Show session dump
Show env dump
Response
Headers:
None
我从这里找到了一个解决方案ExecJS::RuntimeError on Windows 试图遵循 rubytutorial
这是:
对我们有用的修复:在有问题的系统上,找到 ExecJS 的 runtimes.rb 文件。它看起来像这样。复制找到的文件以进行备份。打开原始 runtimes.rb 进行编辑。找到以 JScript = ExternalRuntime.new( 行开头的部分。在该部分中,在包含 :command => "cscript //E:jscript //Nologo //U", 的行上 - 仅删除 //U。然后在包含 :encoding => 'UTF-16LE' # CScript with //U 返回 UTF-16LE - 将 UTF-16LE 更改为 UTF-8 的行上。保存对文件的更改。文件的这一部分现在应该是:
JScript = ExternalRuntime.new( :name => "JScript", :command => "cscript //E:jscript //Nologo", :runner_path => ExecJS.root + "/support/jscript_runner.js", :encoding = > 'UTF-8' # CScript with //U 返回 UTF-16LE ) 接下来,停止然后重新启动 Rails 服务器并在浏览器中刷新产生原始错误的页面。希望页面现在加载没有错误。
但是 runtimes.rb 文件在哪里呢?我找不到类似的东西。我是 Rails 初学者,我们将不胜感激,谢谢。