sassgulp-sassbootstrap-sassnode-sass

Sass import not crawling node_modules to find appropriate package


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.


Solution

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