ExecJS::RuntimeUnavailable in Rails 4.1.4
ExecJS::RuntimeUnavailable in Rails 4.1.4
UPDATE:一切正常!
由于深度,我安装node.js然后得到TZInfo::DataSourceNotFound错误,通过添加gem 'tzinfo-data', platforms: [:mingw, :mswin]
和bundle update
得到解决。
谢谢你!
首先,我是一个完全的rails初学者(只是为了让你知道我是多么的初学者:我觉得自己只是在这里发布的专家),这是我在这里的第一个问题,所以如果我不是很清楚,请原谅我。
所以,我是一个windows 7用户,学习rails与一个月的课程,我遇到了一个错误,而试图:
$ rake routes
rake aborted!
ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://git
hub.com/sstephenson/execjs for a list of available runtimes.
c:/Users/Marc Montagne/Desktop/pinteresting/config/application.rb:7:in `<top (re
quired)>'
c:/Users/Marc Montagne/Desktop/pinteresting/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
或
$ rails server
c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/execjs-2.0.2/lib/execjs/run
times.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://gi
thub.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUn
available)
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/execjs-2.0.2/l
ib/execjs.rb:5:in `<module:ExecJS>'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/execjs-2.0.2/l
ib/execjs.rb:4:in `<top (required)>'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/uglifier-2.4.0
/lib/uglifier.rb:3:in `require'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/uglifier-2.4.0
/lib/uglifier.rb:3:in `<top (required)>'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/
lib/bundler/runtime.rb:72:in `require'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/
lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/
lib/bundler/runtime.rb:70:in `each'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/
lib/bundler/runtime.rb:70:in `block in require'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/
lib/bundler/runtime.rb:59:in `each'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/
lib/bundler/runtime.rb:59:in `require'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/
lib/bundler.rb:132:in `require'
from c:/Users/Marc Montagne/Desktop/pinteresting/config/application.rb:7
:in `<top (required)>'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.4
/lib/rails/commands/commands_tasks.rb:79:in `require'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.4
/lib/rails/commands/commands_tasks.rb:79:in `block in server'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.4
/lib/rails/commands/commands_tasks.rb:76:in `tap'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.4
/lib/rails/commands/commands_tasks.rb:76:in `server'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.4
/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.4
/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
我所理解的是,我有一个问题与ExecJS。作为一个初学者,我甚至不知道ExecJS是什么。
我读了伟大的线程#12520456,而编辑运行时。rb没有解决我的问题,它仍然给了我一个更好的了解情况和愿意解决我的问题,通过修复它,而不是"忽略它"通过添加node.js,特别是考虑到我可以运行我的服务器之前,我想修复我基本上打破了。
我的意思是,我认为我在编辑我的Windows环境的PATH(我甚至不知道这是什么)时做错了什么,以修复我在安装Heroku时遇到的问题。我记得当我在某处阅读时编辑了这一部分,虽然它似乎解决了我的Heroku问题,但我认为它把其他部分搞砸了。
提前感谢您的帮助和理解
Ubuntu Users
我用的是Ubuntu 11.04,遇到了类似的问题。安装Node.js修复了。
从Ubuntu 13.04 x64开始,你只需要运行:
sudo apt-get install nodejs
这将解决问题。CentOS/RedHat用户
sudo yum install nodejs
一个快速而简单的解决方案是取消Gemfile中的这行注释并再次运行bundle install
gem 'therubyracer', platforms: :ruby
@KevinP已经在这里详细回答了这个问题。
按照上面的链接,您需要进入Execjs的runtimes.rb
并更改他的回答中指定的行。之后,重新启动服务器,它应该开始工作。
需要修改的代码块如下所示:
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
)
^感谢Kevin p .
几天前我也回答了这个问题。https://stackoverflow.com/a/24591983/2456549
根据@RedDeath的回答,以下是Alpine用户的方法:
apk add nodejs
- Javascript in partial (Ruby on Rails)
- Angularjs in rails:在不重新加载的情况下更改页面
- Java 脚本或 jquery in rails 应用程序中
- JavaScript 和 radio_button in rails - 状态只检查一次
- Twitter-Bootstrap in Rails 3.2.3
- Ruby array to js array in .js.erb file on rails
- How to position nested form elements in Rails 3
- Rails Country_Select Gem In ReactJs
- Rails 3.2+jQuery+render partial in js.erb=损坏的HTML元素
- How to make a respond_to by AJAX in Rails 3?
- ActionController UnknownFormat Error in rails 4
- Angularjs in rails:添加数据到数据库并显示,而不需要重新加载
- ExecJS::RuntimeUnavailable in Rails 4.1.4
- Rails 4 ExecJS::ProgramError in Listings#index
- Rails 3.1 - JS - Socket.Io-emit in *.js.erb不被执行,并阻止jQuery-Fu
- Raphael Image URI in Rails
- Rails -使用best in place gem创建记录
- CSS in Rails Javascript file
- 呈现js.动词in rails
- ExecJS::RuntimeError in Rails