user1688401
user1688401

Reputation: 1871

Functions may not be defined within control directives or other mixins

In my nodeJS project suddenly it give error.I do not any upgrade or changes. When I write NPM start in command line it give that error

 ERROR in ./~/css-loader?sourceMap!./~/postcss-loader!./~/sass-loader?
sourceMap&outputStyle=expanded&includePaths[]=c:/TFS/rc1/app/scss&includePaths[]

=c:/TFS/rc1/~/compass-mixins/lib&sourceMap&sourceMapContents=true!./app/scss/_toolkit.scss
    Module build failed:
    undefined
     ^
          Functions may not be defined within control directives or other mixins.
          in c:\TFS\rc1\node_modules\compass-mixins\lib\compass\functions\_lists.scss (line 81, column 3)
     @ ./app/scss/_toolkit.scss 4:14-337

I reinstall compass-mixins package but it still give same error.Then I looked _lists.scss that file in 81 line there is a code .I deleted that bu it give same error.What should I do?

@if not(function-exists(compact)) {
  @function compact($vars...) {
    $list: ();
    @each $var in $vars {
        @if $var {
            $list: append($list, $var, comma);
        }
    }
    @return $list;
  }
}

Upvotes: 9

Views: 6196

Answers (5)

shriek
shriek

Reputation: 5823

Btw, there is a PR waiting to be merged for this. But if you want to use this today then there's a fork of the merge too.
If you want to use latter then just put compass-mixins: tjenkinson/compass-mixins in your package.json and all will be good.

Update:- There's also an npm package for the latter mentioned in the PR now

Update 2:- This should no longer be a problem with v0.12.8 now

Upvotes: 1

Vagelis Prokopiou
Vagelis Prokopiou

Reputation: 2693

What I (temporarily) did, was to install globally the node-sass v3.4.2, and then replace the gulp-sass version of node-sass (it is located within gulp-sass/node_modules) with this older one.

sudo npm install -g [email protected];
sudo cp -r /usr/lib/node_modules/node-sass/ /usr/lib/node_modules/gulp-sass/node_modules/;

Upvotes: 1

Sudipto Sarkar
Sudipto Sarkar

Reputation: 356

I had the same issue,please refer to node sass release 3.5.3 is breaking build and force lock gulp-sass to use the specific node sass library using shrinkwrap and avoid using the buggy version of node sass

Upvotes: 2

Vincent Pang
Vincent Pang

Reputation: 432

I also face the similar problem. And my project is using gulp-sass and compass-mixins. As heart.cooks.mind points out that, gulp-sass is depending on node-sass. And node-sass upgrade one of its dependence libsass to version libsass 3.3.3 Delorean since node-sass 3.5.1.

However, one of libsass 3.3.3 Delorean changes is related to this problem:
'Disallow functions to be defined in control directives or mixins (@mgreter, #1550)'

Obviously, _lists.scss in compass-mixins break this rule. Seems someone raise an issue to compass-mixins and they have idea on fixing it.

Before compass-mixins release the issue fixed version, my temporary workaround is to delete node_modules/node-sass manually and npm install [email protected]

Upvotes: 6

heart.cooks.mind
heart.cooks.mind

Reputation: 1165

I am using Gulp. Version 2.3.0 of gulp-sass breaks it. Go back to Version 2.2.0 and you are all fixed.

Edit:

The real culprit is the node module inside the "gulp-sass" node module known as "node-sass". You can see inside "gulp-sass"'s package.json file that it simply pulling version greater than ^3.5.3.

Even if you go back and reinstall "gulp-sass" to 2.2.0, as I suggested earlier, the package.json file in there will still pull "node-sass" greater than ^3.5.3.

If I use the older version of "node-sass" 3.4.2 that error goes away. I don't know how to fix that in an automated way. In a pinch I was able to fix the problem by copying that folder (that is using 3.4.2) from a different project that works. Now it compiles.

Can someone smarter than me figure out a better way to accomplish this result?

Upvotes: 1

Related Questions