javascript - ExecJS::RuntimeUnavailable 在 Rails 4.1.4 中

标签 javascript ruby-on-rails ruby windows execjs

更新:一切正常!

多亏了 deep ,我安装了 node.js 然后得到了一个 TZInfo::DataSourceNotFound 错误,通过添加 gem 'tzinfo-data', platforms: [:mingw, :mswin] bundle 更新

谢谢楼主!


首先,我是一个完全的 Rails 初学者(只是为了让您了解我是多么的初学者:我感觉自己是专家,只是在这里发帖),这是我在这里的第一个问题,所以请原谅我'我不是很清楚。

所以,我是一名 Windows 7 用户,通过一个月类(class)学习 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,虽然编辑 runtimes.rb 没有解决我的问题,但它仍然让我更好地了解情况,并愿意通过修复它而不是通过添加“忽略它”来解决我的问题node.js 特别是考虑到我之前可以运行我的服务器并且我想修复我基本上损坏的东西。

我的意思是,我认为我在编辑我的 Windows 环境的 PATH(我什至不知道这是什么)时做错了什么,以解决我在安装 Heroku 时遇到的问题。我记得我在某个地方读到它时编辑了那部分,虽然它似乎解决了我的 Heroku 问题,但我认为它搞砸了其余部分。

预先感谢您的帮助和理解。

最佳答案

Ubuntu 用户

我在 Ubuntu 11.04 上遇到了类似的问题。安装 Node.js 修复了它。

从 Ubuntu 13.04 x64 开始,您只需要运行:

sudo apt-get install nodejs

这将解决问题。 CentOS/RedHat 用户

sudo yum install nodejs

关于javascript - ExecJS::RuntimeUnavailable 在 Rails 4.1.4 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24609912/

相关文章:

javascript - 在javascript中在图像上绘制矩形

ruby-on-rails - 如何在 RSpec 中使用 class_double stub 类方法?

ruby-on-rails - Active Record 对象重新加载和重新加载!?

ruby-on-rails - Rails、Puma、Sidekiq 如何计算总数据库连接数?

ruby-on-rails - 是否可以将 tinyMCE 与 rails_admin 一起使用?

javascript - 计算a4纸尺寸的div高度

JavaScript 箭头函数赋值

javascript - 如何在单个 html 文件中构建 Angular 应用程序,并将所有脚本内联?

c - 传入 char *argv[] 和声明 char *argv 有什么不同?

ruby - 如何正确地对 Ruby 进行 monkeypatch?