I was upgrading an old grunt setup that I had for one of my websites when I got the error: Fatal error: The implementation option must be passed to the Sass task. This started after I upgraded the version of grunt with all of its dependencies. I was surprised how little I had to change to make this work, my installation was ancient.
As mentioned when I updated my node packages I got the error: The implementation option must be passed to the Sass task. It turns out that in newer versions of Grunt you have to choose whether you wish to use node-sass or dart-sass implementation of sass. This is done by installing either the package of node-sass or dart-sass, below I have added the node-sass package to my json.config:
"devDependencies": {
"grunt": "1.2.1",
"grunt-contrib-clean": "2.0.0",
"grunt-contrib-concat": "1.0.1",
"grunt-contrib-copy": "1.0.0",
"grunt-contrib-jshint": "2.1.0",
"grunt-contrib-uglify": "4.0.1",
"grunt-contrib-watch": "1.1.0",
"grunt-sass": "^3.1.0",
"matchdep": "*",
"node-sass": "^4.14.1" //This one right here
}
I then require this in my grunt.js file and pass it to the implementation property of the options for sass, in older versions of grunt you did not have to do this.:
const sass = require('node-sass'); //this part
grunt.initConfig({
sass:{
options: {
outputStyle: 'compressed',
implementation: sass //and this part
}
}
});
That is basically it. After this my Grunt tasks ran as they always had. I spent several minutes because I forgot to restart my watch task and thought my changes did nothing. By writing this I hope you do not make the same mistake, please let me know in the comments if this helped you :)