ExecJS RuntimeError on Windows While Following Ruby Tutorial
Problem:
You encounter the "ExecJS::RuntimeError" when following the Ruby on Rails tutorial on a Windows machine. The error occurs when including the line "= require_tree ." in the "application.js" file.
Solution:
To resolve the issue, several options are available:
-
Remove "= require_tree ." and Ignore the Problem:
- Removes the line causing the issue, but leaves the underlying problem with ExecJS unresolved.
-
Install Node.js:
- Installs Node.js to use as the JavaScript runtime instead of the default one on your system. This avoids the issue, but requires additional software.
-
Fix the Underlying Problem:
- Modify ExecJS's "runtimes.rb" file to update settings related to the JScript runtime on Windows.
- Specifically, remove "//U" from the command line and change "UTF-16LE" to "UTF-8" in the encoding section.
Detailed Steps for Option 3:
- Locate ExecJS's "runtimes.rb" file on your system.
- Make a backup copy of the file for safety.
- Open the original "runtimes.rb" file for editing.
- Find the section starting with "JScript = ExternalRuntime.new(".
- In the line containing ":command => "cscript //E:jscript //Nologo //U"", remove "//U" only.
- In the line containing ":encoding => 'UTF-16LE' # CScript with //U returns UTF-16LE", change "UTF-16LE" to "UTF-8".
- Save the changes to the file.
- Restart your Rails server and refresh the page in your browser.
The above is the detailed content of Why Am I Getting an ExecJS::RuntimeError on Windows When Following the Ruby on Rails Tutorial?. For more information, please follow other related articles on the PHP Chinese website!