Less.js LoadError-没有要加载的此类文件-主.less文件较少 [英] Less.js LoadError - no such file to load -- less on main .less file

查看:100
本文介绍了Less.js LoadError-没有要加载的此类文件-主.less文件较少的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在一个新项目上测试less.js.我100%肯定javascript文件可以正常加载,但是我的css文件夹中的文件较少,却不断收到此错误.我将在启动前使用less.app对其进行编译,但我宁愿在开发过程中让less.js进行编译.是否存在由于.less或其他原因而导致浏览器无法访问文件的问题?谢谢(运行ubuntu 11.04和ruby v1.9.2,在Firefox和Chrome中出现相同的错误)

I am trying to test out less.js on a new project. I am 100% sure the javascript file is loading fine but I keep getting this error on the less file that is in my css folder. I am going to compile it using the less.app before I launch but I would rather just let less.js do it during development. Is there a problem with it not letting the browser access the file since it is .less or something else? Thanks (running ubuntu 11.04 and ruby v1.9.2, same error in firefox and chrome)

这是我的head.haml文件,我链接到less.js& app.less(均位于正确的文件夹中)

Here is my head.haml file where I link to less.js & app.less (which are both in the correct folders)

%link{:rel => "stylesheet/less", :type=>"text/css", :href => "/assets/css/app.less"}
%script{:src => "/assets/js/less-1.1.3.min.js", :type => "text/javascript"}

这是我打开app.less时浏览器出现的错误

Here is the error I get in the browser when I open up app.less

LoadError at /assets/css/app.less
no such file to load -- less (in /home/blake/biddrr/assets/css/app.less)

Ruby    /home/blake/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/dependencies.rb: in require, line 239
Web GET localhost/assets/css/app.less

推荐答案

我遇到了同样的问题,并且做了一些挖掘工作. no such file to load -- file错误意味着Rails在系统中找不到文件(在我们的情况下为less).

I had the same problem and I did some digging. The no such file to load -- file error means that Rails can't find the file, in our case less, in the system.

这可以很容易地解决,只需进入Gemfile并添加

This can be easily solved by going in the Gemfile and adding

group :assets do
  gem 'less'
end

然后运行bundle install以获得更少的宝石.

After that run a bundle install to get the less gem.

最后重新启动Rails服务器rails s

Finally restart your rails server rails s

我对RoR和Ruby还是陌生的,所以我所做的某些事情可能没有用,或者有更聪明的解决方案.无论如何,这解决了我的问题:)我希望也能为您服务!

I am kinda new to RoR and Ruby so may be some of the things I've done are useless or there are smarter solutions. Anyway this solved my problem :) I hope will work for you too!

这篇关于Less.js LoadError-没有要加载的此类文件-主.less文件较少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆