Sass import not crawling node_modules to find appropriate package

4.7k views Asked by At

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';

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';

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.

2

There are 2 answers

2
Davey On BEST ANSWER

Pass the path as an includes path....

Eg. It will look something like this if you're using gulp

.pipe(sass({
  includePaths: ['node_modules/bootstrap-sass/assets/stylesheets']
}))

Then you should be fine to use:

@import 'bootstrap';
0
DevNebulae On

It will not import stuff like Javascript / Node.js. It will look for the bootstrap file in the same folder as the file which imports it. So yes, you need to use the long path or place the bootstrap file in the same folder.