I generated a page using a controller. But when I go to the localhost:3000/pages/home. I got this error: ExecJS::RuntimeError in Pages#home
@RyanBigg Okay here is the full error code:
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
I found a solution from here ExecJS::RuntimeError on Windows trying to follow rubytutorial
which is:
The Fix that worked for us: On the system having issues, find ExecJS's runtimes.rb file. It looks like this. Make a copy of the found file for backup. Open the original runtimes.rb for editing. Find the section that starts with the line JScript = ExternalRuntime.new(. In that section, on the line containing :command => "cscript //E:jscript //Nologo //U", - remove the //U only. Then on the line containing :encoding => 'UTF-16LE' # CScript with //U returns UTF-16LE - change UTF-16LE to UTF-8 . Save the changes to the file. This section of the file should now read:
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 ) Next, stop then restart your Rails server and refresh the page in your browser that produced the original error. Hopefully the page loads without error now.
But where is the runtimes.rb file? I could not find anything like that. I'm rails beginner and your help will be appreciated, thanks.