Sass导入不对node_modules进行爬网以查找适当的包 [英] Sass import not crawling node_modules to find appropriate package
问题描述
我正在使用bootstrap-sass。节点模块已安装。我应该可以在任何.scss文件中使用以下行导入到适当的工作表中
I am using bootstrap-sass. The node module is installed. I should expect I can, in any .scss file, use the below line to import into an appropriate sheet
@import 'bootstrap';
我的理解是,编译器爬升直到找到package.json并跳入node_modules时,应该发生什么,并找到适当的软件包。而是出现以下错误。
My understanding is what should happen is the compiler crawls up until it finds package.json, hops into node_modules, and finds the appropriate package. Instead I am getting the below error.
错误:找不到导入文件或文件不可读:引导程序
Error: File to import not found or unreadable: bootstrap
如果我用以下完全限定的路径替换导入,则一切正常。
If I replace my import with a fully qualified path as below, then everything works gravily.
@import '../../node_modules/bootstrap-sass/assets/stylesheets/bootstrap';
我正在使用gulp-sass进行编译。猜猜我只有一些小的配置位,但我不知道它是什么。
I am using gulp-sass to compile. Guessing I just have some minor config bits off but I can't figure out what it is.
推荐答案
将路径作为包括路径...。
Pass the path as an includes path....
例如。如果您使用的是gulp
Eg. It will look something like this if you're using gulp
.pipe(sass({
includePaths: ['node_modules/bootstrap-sass/assets/stylesheets']
}))
然后您应该可以使用:
@import 'bootstrap';
这篇关于Sass导入不对node_modules进行爬网以查找适当的包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!