简体   繁体   English

Sass :: SyntaxError:导入未找到或不可读的文件:bourbon / bourbon

[英]Sass::SyntaxError: File to import not found or unreadable: bourbon/bourbon

I've installed rvm and bourbon. 我已经安装了rvm和bourbon。 I then installed bourbon into my /css directory. 然后我将波旁威士忌安装到我的/ css目录中。 However when I try 但是,当我尝试

@import 'bourbon/bourbon'; 

I get this error: 我收到此错误:

Sass::SyntaxError: File to import not found or unreadable: bourbon/bourbon.

I've checked out other threads with the same issue but none seemed to solve my problem. 我已经检查了其他线程有相同的问题,但似乎没有解决我的问题。 How can I get this error to go away and for bourbon to import correctly? 如何让这个错误消失并让波本威士忌正确导入?

try this out: 试试这个:

In your Gemfile: 在你的Gemfile中:

gem 'bourbon'

Then run: 然后运行:

bundle install

from github documentation of bouron 来自bouron github文档

Non-Rails projects 非Rails项目

Bourbon includes an easy way to generate a directory with all the necessary files. Bourbon包含一种生成包含所有必要文件的目录的简便方法。 For command line help: $ bourbon help or visit the Command line tools wiki Install (Bourbon v3.0+) 对于命令行帮助:$ bourbon帮助或访问命令行工具wiki安装(Bourbon v3.0 +)

gem install bourbon

Install Bourbon into the current directory by generating the bourbon folder: 通过生成波旁文件夹将Bourbon安装到当前目录中:

bourbon install

The generated folder will contain all the mixins and other necessary Bourbon files. 生成的文件夹将包含所有mixins和其他必要的波旁文件。 It is recommended not to add or modify the Bourbon files so that you can update Bourbon easily. 建议不要添加或修改波旁文件,以便您可以轻松更新波旁威士忌。

You can specify a target directory using the path flag: 您可以使用路径标志指定目标目录:

bourbon install --path my/custom/path/

Import 进口

Lastly, import the mixins at the beginning of your stylesheet(s): 最后,在样式表的开头导入mixins:

@import 'bourbon/bourbon';

Note: Bourbon no longer requires a custom sass --watch command for Bourbon v3.0+

It is important to note where the installation of bourbon is (assuming you're working on your local machine). 重要的是要注意波旁威士忌的安装位置(假设您正在使用本地机器)。 When installing you can determine a custom install like this: 安装时,您可以确定这样的自定义安装:

bourbon install --path my/custom/path/

It would be a good idea to place it in the directory that you usually save your local web files for easy access. 将它放在通常保存本地Web文件的目录中以便于访问是个好主意。 I have mine installed in the user directory currently which is sort of pain, but I have to call in my bourbon like this in my sass files: 我已经在我的用户目录中安装了当前有点痛苦,但我必须在我的sass文件中调用我的波旁威士忌:

@import '/Users/myusername/rubygems/bourbon/_bourbon.scss';

Yes this is actually late, just got into the same problem using Rails 4.2.5.1 . 是的,这实际上是晚了,只是使用Rails 4.2.5.1遇到了同样的问题。 I think in your own case, the problem being you didn't rename your asset pipeline (css file) to carry the extension .scss . 我认为在您自己的情况下,问题是您没有重命名您的资产管道(css文件)来携带扩展名.scss

Here is how I fixed it : 以下是我修复它的方法

How to get around it Bourbon for Ruby on Rails 4.2+ 如何绕过它Bourbon for Ruby on Rails 4.2+

  1. Add Bourbon to your Gemfile: 将Bourbon添加到您的Gemfile:

    gem 'bourbon'

    Then run: 然后运行:

    bundle install

    Note : In your asset pipeline, if your stylesheet is still asset named application.css , you need to rename it to to application.scss . 注意 :在资产管道中,如果样式表仍然是名为application.css资产,则需要将其重命名为application.scss

    In my own case my pipeline is named application.css.scss and it worked because I have my extension still append to .scss extension. 在我自己的情况下,我的管道名为application.css.scss ,它起作用,因为我的扩展名仍然附加到.scss扩展名。

  2. Delete all Sprockets directives in application.scss (require, require_tree and require_self) and use Sass's native @import instead. 删除application.scss中的所有Sprockets指令(require,require_tree和require_self),然后使用Sass的本机@import。 The reason being as it is explained here . 原因正如此处所解释的那样。 Such that your application.scss will Import Bourbon at the beginning like this below: 这样你的application.scss在开头导入Bourbon 如下所示:

    Example: 例:

      @import "bourbon"; @import "bourbon"; @import "bootstrap-sprockets"; @import "bootstrap"; @import "social-share-button"; 
  3. Then restart your server by running 然后通过运行重新启动服务器

    rails server

With all these, you should be up and running. 有了这些,你应该开始运作。 For more info, see https://github.com/thoughtbot/bourbon 有关详细信息,请参阅https://github.com/thoughtbot/bourbon

I came across this issue when I upgraded versions of Rails (3.2 -> 5.0). 当我升级Rails版本(3.2 - > 5.0)时,我遇到了这个问题。 During the process, I left behind group :assets in the Gemfile. 在此过程中,我留下了group :assets Gemfile中的group :assets Taking bourbon and other gems out of that group fixed the issue. 从该组中取出bourbon和其他宝石解决了这个问题。

Try this (if you are using Rails) : 试试这个 (如果你使用的是Rails)

  1. Open your Gemfile 打开你的Gemfile
  2. Make sure gem bourbon exists but is not in any groups 确保gem bourbon存在但不属于任何群体
  3. Run bundle install 运行bundle install

This happened to a colleague of mine when he upgraded versions of Rails (3.2 -> 5.0): he accidentally left some gems in the group :assets , which was deprecated in Rails 4. 当他升级版本的Rails(3.2 - > 5.0)时,我的同事发生了这种情况:他意外地在组中遗留了一些宝石:assets ,在Rails 4中被弃用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM