Upon completing my gulp task styles, I encountered the following error:
Error in plugin "sass"
Message:
static\node_modules\bootstrap-material-design\scss\_variables.scss
Error: File to import not found or unreadable: ~bootstrap/scss/functions.
on line 56 of static/node_modules/bootstrap-material-design/scss/_variables.scss
from line 2 of static/node_modules/bootstrap-material- design/scss/_core.scss
from line 3 of static/node_modules/bootstrap-material- design/scss/bootstrap-material-design.scss
@import "~bootstrap/scss/functions"; // from bootstrap node_module
^
I have confirmed that the files are located where they should be. Therefore, I am uncertain about what could be causing the issue. This is the structure of my project:
Project/
gulpfile.js
package.json
package-lock.json
node_modules/
bootstrap/
bootstrap-material-design/
gulp-sass/
gulp/
static/
node_modules/
bootstrap/
scss/
_functions.scss
bootstrap-material-design/
scss/
gulp-sass/
gulp/
.
//gulpfile.js
var gulp = require('gulp');
var sass = require('gulp-sass');
//style paths
var sassFiles = 'static/node_modules/bootstrap-material-design/scss/**/*.scss',
cssDest = 'static/node_modules/bootstrap-material-design/dist/css/';
gulp.task('default', function () {
console.log('GULP GULP GULP')
});
gulp.task('styles', function () {
gulp.src(sassFiles)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(cssDest));
});
gulp.task('watch', function () {
gulp.watch(sassFiles, ['styles']);
});
Excerpt from package.json
"dependencies": {
"bootstrap": "^4.1.1",
"bootstrap-material-design": "^4.1.1",
},
"devDependencies": {
"gulp": "^3.9.1",
"gulp-ng-annotate": "^2.1.0",
"gulp-uglify": "^3.0.0"
}
EDIT
After manually setting the path for functions (inside Bootstrap's _variables.scss), the task was successful and moved on to the next import it couldn't find.
Error in plugin "sass"
Message:
static\node_modules\bootstrap-material-design\scss\_variables.scss
Error: File to import not found or unreadable: ~bootstrap/scss/variables.
on line 57 of static/node_modules/bootstrap-material- design/scss/_variables.scss
from line 2 of static/node_modules/bootstrap-material- design/scss/_core.scss
from line 3 of static/node_modules/bootstrap-material- design/scss/bootstrap-material-design.scss
@import "~bootstrap/scss/variables"; // from bootstrap node_module
^
variables.scss
56: @import "C:/Users/PC/Documents/Git/Project/static/node_modules/bootstrap/scss/functions"; // from bootstrap node_module
This hardcoded solution doesn't seem entirely satisfactory. The root cause of why it isn't working out of the box remains unclear. Could it be that the tilde symbol is not being recognized somehow?
Original variables.scss
56: @import "~bootstrap/scss/functions"; // from bootstrap node_module