我正在使用 bootstrap-sass。节点模块已安装。我应该期望我可以在任何 .scss 文件中使用下面的行导入到适当的工作表中
@import 'bootstrap';
我的理解是编译器会向上爬直到找到 package.json,然后跳转到 node_modules 并找到合适的包。相反,我收到以下错误。
Error: File to import not found or unreadable: bootstrap
如果我用下面的完全限定路径替换我的导入,那么一切都会正常工作。
@import '../../node_modules/bootstrap-sass/assets/stylesheets/bootstrap';
我正在使用 gulp-sass 进行编译。我猜我只是关闭了一些小的配置位,但我不知道它是什么。
最佳答案
将路径作为包含路径传递....
例如。如果你使用 gulp,它看起来像这样
.pipe(sass({
includePaths: ['node_modules/bootstrap-sass/assets/stylesheets']
}))
那么你应该可以使用:
@import 'bootstrap';
关于Sass 导入不抓取 node_modules 以找到合适的包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41511455/