Koalaphant
Koalaphant

Reputation: 13

I am having issues running the gulp.watch task in command prompt

I am new to gulp, so I am still trying to understand how to use it.

(Gulp version: 3.9.1)

In the gulpfile.js I have the following code:

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

gulp.task('styles', function() {
    gulp.src('app/css/styles.css')
        .pipe(autoprefixer())
        .pipe(gulp.dest('app/processedcss'))
});

gulp.task('watch', function() {
    gulp.watch('app/css/styles.css'), ['styles']);
});

I receive this message in my command prompt when trying to run gulp watch:

> SyntaxError: Unexpected token )
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at execute (C:\Users\Andrew\AppData\Roaming\npm\node_modules\gulp-
    cli\lib\versioned\^3.7.0\index.js:26:18)

When I remove the watch task code, the autoprefixer works perfectly, so I am confident that isn't the issue.

This isn't the plugin gulp-watch but the built-in gulp.watch.

Thanks for your help in advance!

Upvotes: 1

Views: 301

Answers (1)

AJ X.
AJ X.

Reputation: 2770

The debug message is correct. Remove the ')'

gulp.task('watch', function() {
    gulp.watch('app/css/styles.css', ['styles']);
});

Upvotes: 1

Related Questions