我尝试为 Rails 安装 Bootstrap,但我总是遇到这个错误:
Please install gem 'therubyracer' to use Less.
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/less-2.4.0/lib/less/java_sc
ript/v8_context.rb:2:in `require': cannot load such file -- v8 (LoadError)
为了避免这个问题,我安装了 nodejs 并在 config/boot 中添加了这一行:
ENV['EXECJS_RUNTIME'] = 'Node'
所以当我重新启动我的 webrich 服务器时,我在 public indey 上看到 javascript 运行时现在是 nodejs。然后我重新安装了 twitter bootstrap,但得到了同样的错误。我使用 Rails 4.0,希望有人对我有建议?谢谢
最佳答案
对于 Rails 中的 Javascript 运行时:不要在你的 gem 文件中使用 'therubyracer' 或 'execjs'。
首先删除你的 Gemfile 中的那些,然后删除 Gemfile.lock。
然后在安装 nodejs 之后执行此操作。
sudo apt-get install nodejs
我正在考虑您的环境是 ubuntu/linux。所以对于上述命令的使用
并捆绑您的应用。
希望对您有所帮助。
关于ruby-on-rails - 为 V8 Rails 安装 Nodejs 以减少使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19185364/