本文翻译自:ExecJS and could not find a JavaScript runtime
I'm trying to use the Mongoid / Devise Rails 3.1 template ( Mongoid and Devise ), and I keep getting an error stating ExecJS cannot find a JavaScript runtime. 我正在尝试使用Mongoid / Devise Rails 3.1模板 ( Mongoid和Devise ),并且我不断收到错误,指出ExecJS无法找到JavaScript运行时。 Fair enough when I didn't have any installed, but I've tried installing Node.js , Mustang and the Ruby Racer , but nothing is working. 当我没有安装任何东西时足够公平,但我已经尝试安装Node.js , Mustang和Ruby Racer ,但没有任何工作。
I could not find a JavaScript runtime. 我找不到JavaScript运行时。 See sstephenson/ExecJS (GitHub) for a list of available runtimes ( ExecJS::RuntimeUnavailable
). 请参阅sstephenson / ExecJS (GitHub)以获取可用运行时列表( ExecJS::RuntimeUnavailable
)。
What do I need to do to get this working? 为了让这个工作,我需要做什么?
#1楼
参考:https://stackoom.com/question/QMJX/ExecJS并找不到JavaScript运行时
#2楼
Add following gems in your gem file 在gem文件中添加以下gem
gem 'therubyracer'
gem 'execjs'
and run 并运行
bundle install
you are done :) 你做完了:)
#3楼
仅供参考,这为我解决了这个问题...这是一个路径问题: http : //forums.freebsd.org/showthread.php? t = 35539
#4楼
I started getting this problem when I started using rbenv with Ruby 1.9.3 where as my system ruby is 1.8.7. 当我开始在Ruby 1.9.3中使用rbenv时,我开始遇到这个问题,因为我的系统ruby是1.8.7。 The gem is installed in both places but for some reason the rails script didn't pick it up. gem安装在两个地方,但由于某种原因,rails脚本没有拿起它。 But adding the "execjs" and "therubyracer" to the Gemfile did the trick. 但是将“execjs”和“therubyracer”添加到Gemfile就可以了。
#5楼
Don't Use RubyRacer as it is bad on memory. 不要使用RubyRacer因为内存不好。 Installing Node.js as suggested by some people here is a better idea. 按照一些人的建议安装Node.js是个更好的主意。
This list of available runtimes that can be used by ExecJs Library also documents the use of Node.js ExecJs Library可以使用的可用运行时列表也记录了Node.js的使用
https://github.com/sstephenson/execjs https://github.com/sstephenson/execjs
So, Node.js is not an overkill, and much better solution than using the RubyRacer. 因此,与使用RubyRacer相比,Node.js不是一种矫枉过正的解决方案。
#6楼
In your gem file Uncomment this line. 在您的gem文件中取消注释此行。
19 # gem 'therubyracer', platforms: :ruby 19#gem'therubyracer',平台:: ruby
And run bundle install 并运行bundle install
You are ready to work. 你准备工作了。 :) :)