0

Browser console doesn't watch errors but when I try to run the command in git console I have got a error.

let gulp = require('gulp'); let sass = require('gulp-sass'); let watch = require('gulp-watch'); let browserSync = require('browser-sync'); gulp.task('sass', function() { return gulp.src('src/scss/index.scss') .pipe(sass().on('error', sass.logError)) .pipe(gulp.dest('src/css/index.css')) }); gulp.task('sass:watch', function() { gulp.watch('src/scss/index.scss', ['sass']); }); gulp.task('browser-sync', function() { browserSync({ server: { baseDir: 'src' }, notify: false }); });

Link to my repository https://github.com/dzhulay/Step-Ham

2
  • Can you please post the errors? Commented Sep 1, 2019 at 11:59
  • Error: watching src/scss/index.scss: watch task has to be a function (optionally generated by using gulp.parallel or gulp.series) at Gulp.watch (C:\Step-Ham\node_modules\gulp\index.js:31:11) at C:\Step-Ham\gulpfile.js:14:10 at taskWrapper (C:\Step-Ham\node_modules\undertaker\lib\set-task.js:13:15) at bound (domain.js:402:14) at runBound (domain.js:415:12) at asyncRunner (C:\Step-Ham\node_modules\async-done\index.js:55:18) at process._tickCallback (internal/process/next_tick.js:61:11) Commented Sep 1, 2019 at 12:05

1 Answer 1

1

The gulp.watch function requires a list of files and a function as second parameter.

You have to generate the function either with gulp.parallel or gulp.series, such as in your case:

gulp.task('watch', function() { gulp.watch('src/scss/index.scss', gulp.series('sass')); }); 

Also, in order to avoid the "file exists" error as specified in your comment, please implement "gulp-chmod" in your sass task, such as:

var chmod = require('gulp-chmod'); gulp.task('sass', function() { return gulp.src('src/scss/index.scss') .pipe(chmod(0o755)) .pipe(sass().on('error', sass.logError)) .pipe(gulp.dest('src/css/index.css')) }); 
Sign up to request clarification or add additional context in comments.

8 Comments

Now I have an error EEXIST: file already exists, mkdir 'C:\Step-Ham\src\css\index.css'
I tried to use that variant and now I have this Error: watching src/scss/index.scss: watch task has to be a function (optionally generated by using gulp.parallel or gulp.series) at Gulp.watch (C:\Step-Ham\node_modules\gulp\index.js:31:11) at C:\Step-Ham\gulpfile.js:13:10 at taskWrapper (C:\Step-Ham\node_modules\undertaker\lib\set-task.js:13:15) at bound (domain.js:402:14) at runBound (domain.js:415:12) at asyncRunner (C:\Step-Ham\node_modules\async-done\index.js:55:18) at process._tickCallback (internal/process/next_tick.js:61:11)
Without "require('gulp-watch');"?
I had update my code, and I tried run it with 'require gulp' and without, but nothing work
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.