Reputation: 642
I have a very simple Gulpfile:
var gulp = require('gulp'),
prefix = require('gulp-autoprefixer'),
gsass = require('gulp-sass');
gulp.task('sass', function() {
gulp.src('scss/*.scss')
.pipe(gsass({
unixNewlines: true,
style: 'compact'
}))
.pipe(prefix('last 2 versions'))
.pipe(gulp.dest('.'));
});
gulp.task('default', ['sass'], function() {
gulp.watch('scss/*.scss', ['sass']);
});
When the SCSS file is changed and the sass
task runs, I occasionally (about 10% of the time) get the following error message on the console:
events.js:72
throw er; // Unhandled 'error' event
^
Error: EBUSY, open 'C:\whatever\scss\main.scss'
The error in question happens during the call to gulp.src
. Passing the read: false
option into that function stops the error from happening (but, of course, prevents sass from working).
This error is a problem because the watch task stops running whenever the error is encountered. Neither gulp-plumber
nor .on('error', ...)
help with this problem.
Is there a way to work around this issue? I'm on Windows, if it's relevant.
A few more relevant points:
gulp.src
tries to read the file while Sublime is still writing to it (though I'm not entirely sure).Upvotes: 1
Views: 3368
Reputation: 432
There is a decent chance you have one of your files open in Microsoft Word. Word locks up access to the file. Completely exit MS Word and re-build. Fixed the problem for me. Hope it helps!
Upvotes: 3
Reputation: 10156
So I'm not entirely sure about this because I don't run Windows, but here's some pointers:
return
your streams from gulp tasks. That way gulp's task manager knows when the task finishes and can properly sequence your dependencies../dist/css
or something along those lines.gulp.src
etc.Upvotes: 0