sindresorhus / gulp-autoprefixer

Prefix CSS
MIT License
692 stars 50 forks source link

SyntaxError: Use of const in strict mode. #91

Closed AndrewNimbler closed 6 years ago

AndrewNimbler commented 6 years ago

I'm trying to run a autoprefixer task in gulp using the standard example code from the readme file inside a external file loaded into the gulpfile using 'module.exports' & I get a 'SyntaxError: Use of const in strict mode.' error message, am I doing anything wrong? I've tried adding 'use strict'; to all the files & installing 'gulp-util', but nothing seems to work.

Edit: I tried this with gulp autoprefixer v3.1.1 & after I installed the es6 promise-polyfill it worked.

Error message:

C:\user\project\themes\main>gulp

C:\user\project\themes\main\node_modules\gulp-autoprefixer\index.js:2
const gutil = require('gulp-util');
^^^^^
SyntaxError: Use of const in strict mode.
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at module.exports (C:\user\project\themes\main\gulp\autoprefixer.js:3:
    at gulp.task.cwd (C:\user\project\themes\main\gulpfile.js:27:51)
    at Array.forEach (native)
    at Object.<anonymous> (C:\user\project\themes\main\gulpfile.js:26:9)

Task configuration:

module.exports = function(gulp, config, livereload) {

    var autoprefixer = require('gulp-autoprefixer');

    gulp.task('autoprefixer', function() {
        return gulp.src('css/styles.css')
        .pipe(autoprefixer({

            browsers: ["last 2 versions"],
            cascade: false

        }))
        .pipe(gulp.dest('css'));
    });

};

Environment:

sindresorhus commented 6 years ago

'SyntaxError: Use of const in strict mode.'

That means you're running it in a Node.js version lower than version 4, despite what you added in the Environment section. You probably have multiple Node.js versions installed and somehow and an old one is used.