The implementation option must be passed to the Sass task
Asked Answered
S

3

24

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.

Spiritual answered 14/8, 2018 at 20:51 Comment(1)
the sass task might be needed to help you outBendwise
T
51

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

Thomasinathomasine answered 14/11, 2018 at 19:53 Comment(0)
I
4

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

Individual answered 23/6, 2021 at 17:19 Comment(0)
W
-1

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
},
Woodhouse answered 8/11, 2018 at 21:41 Comment(1)
implementation: 'sass' broke mine. implementation: sass workedWnw

© 2022 - 2024 — McMap. All rights reserved.