. Advertisement .
..3..
. Advertisement .
..4..
Node.js is a software system designed for writing scalable Internet applications, especially web servers. The program is written in JavaScript, using event-driven, asynchronous I/O to minimize overhead and maximize scalability.
While performing your task, you receive the: gulp-sass 5 does not have a default Sass compiler; please set one yourself. Both the sass and node-sass packages are permitted.
This error was very common that any coder could face. So, when does it happen, and is it fixable? Let us collaborate to identify the most effective techniques.
Why Did The: gulp-sass 5 does not have a default Sass compiler; please set one yourself. Both the sass and node-sass packages are permitted Occur?
You want to use gulp-sass and sass, but you get the following error.
Error in plugin "gulp-sass"
Message:
gulp-sass 5 does not have a default Sass compiler; please set one yourself.
Both the `sass` and `node-sass` packages are permitted.
For example, in your gulpfile:
Here is your code:
var sass = require('gulp-sass')(require('sass'));
In another case, our code is:
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'));
}
The Best Solutions
To solve this error, you may use the following solutions list below. These methods would be based on the version that you are using.
Solution 1:
You can try this code to import instead of requiring it.
import gulpSass from "gulp-sass";
import nodeSass from "node-sass";
const sass = gulpSass(nodeSass);
Solution 2:
You can try this code to import instead of requiring it.
import dartSass from 'sass';
import gulpSass from 'gulp-sass';
const sass = gulpSass( dartSass );
Solution 3:
It can be solved by adding the standard sass npm npm install --save-dev sass.
Adding the second section of the error message to the variable like const sass = require('gulp-sass')(require('sass'));
Then, In install SASS and gulp-sass.
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 }
Conclusion
If you’re confused by the: gulp-sass 5 does not have a default Sass compiler; please set one yourself. Both the sass and node-sass packages are permitted; the above solutions are the most effective.
Even if you still need help or have other questions, there is a large community to which you can turn, and everyone is usually eager to help. Finally, we wish all of our readers a wonderful day full of new ideas.
Leave a comment