Less.js LoadError - 没有要加载的文件 - 主 .less 文件上的 less

发布于 2024-12-02 02:58:49 字数 837 浏览 7 评论 0原文

我正在尝试在新项目上测试 less.js。我 100% 确定 javascript 文件加载正常,但我在 css 文件夹中的 less 文件上不断收到此错误。我将在启动之前使用 less.app 来编译它,但我宁愿让 less.js 在开发过程中完成它。由于文件是 .less 或其他原因,它是否存在不允许浏览器访问该文件的问题?谢谢(运行 ubuntu 11.04 和 ruby​​ v1.9.2,firefox 和 chrome 中也出现同样的错误)

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

%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 时在浏览器中收到的错误

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

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)

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"}

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

朕就是辣么酷 2024-12-09 02:58:49

我也遇到了同样的问题,我做了一些挖掘。
no such file to load -- file 错误意味着 Rails 在系统中找不到该文件,在我们的例子中为 less

通过进入 Gemfile 并添加

group :assets do
  gem 'less'
end

之后运行 bundle install 来获取 less gem。

最后重新启动你的rails服务器rails s

我对RoR和Ruby有点陌生,所以可能我所做的一些事情是无用的或者有更聪明的解决方案。无论如何,这解决了我的问题:)我希望也能为你工作!

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.

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

group :assets do
  gem 'less'
end

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

Finally restart your rails server rails s

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!

茶花眉 2024-12-09 02:58:49

只需将 gem 'less' 放入 gemfile 的 asset 部分即可。并重新启动您的服务器。

Just put gem 'less' into assets section in your gemfile. And restart your server.

梅倚清风 2024-12-09 02:58:49

您可能需要在 Web 服务器上分配 .less MIME 类型,以确保它知道如何处理此文件。

You may need to assign a .less mime type on your web server to ensure it knows what to do with this file.

依 靠 2024-12-09 02:58:49

查看您的网络服务器终端。我正在使用 WEBrick 并在经历此 http://railscasts.com/episodes/328-twitter-bootstrap-basics?view=asciicast 截屏视频。全部我修复它是重置网络服务器。

Look on your web server terminal. I'm using WEBrick and got "ActionView::Template::Error (no such file to load -- less" after going through this http://railscasts.com/episodes/328-twitter-bootstrap-basics?view=asciicast screencast. All I did to fix it was reset the web-server.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文