The implementation option must be passed to the Sass task

17.4k Views Asked by At

Running grunt - I get this error message:

Running "sass:all" (sass) task
Fatal error: The implementation option must be passed to the Sass task

I've tried re-installing grunt, node, npm, dependencies - but I always come back to this error I can't get past.

Should I post my Gruntfile.js? Frankly, this was set up by a third-party and we don't use it often - I'm thinking maybe we should start from the ground up because it is from about 4 years ago originally... but wondering if anyone has seen this error before and knows of a fix/workaround.

3

There are 3 best solutions below

1
On

UPDATE: Only works for grunt-sass 2.x

I had this problem when upgrading from grunt-sass 1.x to 2.x. This solved it for me:

Add implementation: 'sass' to your sass.options object in Gruntfile.js like so:

options: {
    implementation: 'sass',
    outputStyle: 'expanded',
    sourceMap: true,
    quiet: true // stop depreciation errors
},
0
On

With the update to grunt-sass 3, you have to choose whether you want to use node-sass or dart-sass to compile For node-sass you need to install the module with:

$ npm install --save-dev node-sass 

In you gruntfile, you than need to add node-sass as requirement and add the define constant as implementation option:

const sass = require('node-sass');

require('load-grunt-tasks')(grunt);

grunt.initConfig({
    sass: {
        options: {
            implementation: sass,
            sourceMap: true
        },
        dist: {
            files: {
                'main.css': 'main.scss'
            }
        }
    }
});

See also official page for more details: https://www.npmjs.com/package/grunt-sass

0
On

use this

   **const sass = require("node-sass");**

**grunt.initConfig({
sass: {
  options: {
    implementation: sass,
    sourceMap: true,
  },
  dist: {
    files: {
      "css/styles.css": "css/styles.css",
    },
  },
},

});

This will help you solve the problem