scniro/gulp-clean-css

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

webinarium opened this issue · 7 comments

After upgrade to 3.1.0 my Gulp file fails as below:

node_modules/gulp-clean-css/index.js:14
  let transform = function (file, enc, cb) {
  ^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/home/artem/Workspace/etraxis/etraxis/gulpfile.js:14:16)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)

I'm not an expirienced frontend developer, I'm a backend guy, who uses Gulp to maintain LESS/JS assets in Symfony projects. I understand use replaced vars with lets but not sure how to deal with your module now.

Any help will be appreciated. Thank you!

What version of node.js are you using? let should be supported in 4.x. I can't support below 4.x. Its the ie8 argument all over again...

let me know, thanks

It's 4.2.6. I'm running ubuntu 16.10 and have installed both npm and node from the official repositories.

$ nodejs --version
v4.2.6

$ npm --version
3.5.2

Have you tried using the --harmony flag? e.g. node --harmony yourMinifyScript.js

No, it means I need to patch the gulp executable that comes from vendor's repository, which seems a workaround I would like to avoid.

Currently I fix the issue by adding "use strict"; to the index.js of your module. Do you think you can take this change into the module for permanent? I can make a PR if you'd like.

3.1.1 published. So the use strict works fine for you?

Have tried 3.1.1 - works for me like a charm now, thank you!

great to hear! Thank for bringing this up so promptly