gulp-sass 5 does not have a default Sass compiler; please set one yourself
Solution 1
I had this problem and found that adding the standard sass npm npm install --save-dev sass
and then adding the second section of the error message to my variable so that it looks like this const sass = require('gulp-sass')(require('sass'));
worked.
Solution 2
If you, like me, use a modular system. Then this solution should help you!
You need to install SASS
It is also necessary that the gulp-sass be installed
import pkg from 'gulp';
const { src, dest, series, watch } = pkg;
import concat from 'gulp-concat'
import dartSass from 'sass'
import gulpSass from 'gulp-sass'
const sass = gulpSass(dartSass)
function scss() {
return src('app/scss/**/*.scss', { sourcemaps: true })
.pipe(sass.sync().on('error', sass.logError)) // scss to css
.pipe(concat('style.min.css'))
.pipe(dest(config.build.style, { sourcemaps: '../sourcemaps/' }))
}
async function builds() { scss() }
export { builds }
Related videos on Youtube
Zia Ansari
Updated on June 04, 2022Comments
-
Zia Ansari almost 2 years
Error in plugin "gulp-sass" Message:
gulp-sass 5 does not have a default Sass compiler; please set one yourself. Both the
sass
andnode-sass
packages are permitted. For example, in your gulpfile:var sass = require('gulp-sass')(require('sass'));
This is my code below . It says var sass = require('gulp-sass')(require('sass')); in the error but I am using import and none of the solution worked for me I am new to this and the cli version is 2.3.0 local version is 4.0.2 please give me a solution I am stuck here for days
import gulp from 'gulp'; import sass from 'gulp-sass'; import yargs from 'yargs'; const PRODUCTION = yargs.argv.prod; export const styles = () => { return gulp.src('src/assets/scss/bundle.scss') .pipe(sass().on('error', sass.logError)) .pipe(gulp.dest('dist/asset/css')); }
-
Paul over 2 yearsI fixed this but only by installing SASS and not the 2nd thing. Adding
(require('sass'))
to the end of mysass =
statement just returnsTypeError: sass is not a function
. -
KulaGGin over 2 yearsIt's so bad that after installing the gulp-sass I have to get an error and then google how to fix it. Basically, after installing gulp-sass everyone installs a broken plugin.
-
Shashank Bhatt over 2 yearsAs it says to set compiler in your code, sass.compiler = require('sass'); also works fine.