Closed fraserxu closed 10 years ago
I have a similar
events.js:72
throw er; // Unhandled 'error' event
^
Error: watch EPERM
at errnoException (fs.js:1019:11)
at FSEvent.FSWatcher._handle.onchange (fs.js:1037:26)
Yup, same issue here. I can work around it by prepending 'return' on the gulp object like so
gulp.task('clean', function() {
return gulp.src(['my_build_path'], {read: false})
.pipe(clean({force: true}));
});
not sure why this fixes the problem though...
I'm guessing this is caused by the asynchronous removal of the files, and you have other tasks which are writing files into the directory before it finishes being deleted. One of Gulp's documented ways of handling asynchronous tasks is to return the stream from the function. See https://github.com/gulpjs/gulp/blob/master/docs/API.md#return-a-stream
I believe that is why it works for you @ddarbyson.
@iambrandonn Agreed and thanks
Thanks, you are correct @iambrandonn
Feel free to close the ticket...
I get this error, and all my gulp tasks return their streams:
var gulp = require('gulp-help')(require('gulp')),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
browserify = require('browserify'),
reactify = require('reactify'),
less = require('gulp-less'),
clean = require('gulp-clean'),
streamify = require('gulp-streamify'),
source = require('vinyl-source-stream'),
LessPluginCleanCSS = require("less-plugin-clean-css"),
LessPluginAutoPrefix = require('less-plugin-autoprefix'),
cleancss = new LessPluginCleanCSS({advanced: true}),
autoprefix = new LessPluginAutoPrefix({browsers: ["last 2 versions"]});
gulp.task('clean', 'delete built files', function() {
return gulp.src('./build', {read: false})
.pipe(clean());
});
gulp.task('build:js', 'build & minify just application javascript', function(){
return browserify('./src/jsx/index.jsx')
.transform(reactify)
.bundle()
.pipe(source('app.js'))
.pipe(streamify(uglify()))
.pipe(gulp.dest('./build/app'));
});
gulp.task('build:css', 'build & minify just application CSS', function(){
return gulp.src('./src/less/app.less')
.pipe(less({paths: ['./src/less'], plugins: [autoprefix, cleancss]}))
.pipe(gulp.dest('./build/app'));
});
gulp.task('build:img', 'optimize images', function(){
return gulp.src('./src/images/**/*')
.pipe(imagemin({}))
.pipe(gulp.dest('./build/app/images'));
});
// just build, don't minify
gulp.task('build:js:dev', false, function(){
return browserify('./src/jsx/index.jsx')
.transform(reactify)
.bundle()
.pipe(source('app.js'))
.pipe(gulp.dest('./build/app'));
});
// just build, don't minify & clean
gulp.task('build:css:dev', false, function(){
return gulp.src('./src/less/app.less')
.pipe(less({paths: ['./src/less'], plugins: [autoprefix]}))
.pipe(gulp.dest('./build/app'));
});
// copy static assets
gulp.task('copy:static', false, function(){
return gulp.src('./src/static/**/*')
.pipe(gulp.dest('./build/app'));
});
gulp.task('build', 'build application CSS & javascript for production', ['clean', 'copy:static', 'build:img', 'build:css','build:js']);
gulp.task('watch', 'watch for changes, for development', ['clean', 'copy:static', 'build:img', 'build:css:dev','build:js:dev'], function(){
gulp.watch('./src/jsx/**/*.jsx', ['build:js:dev']);
gulp.watch('./src/less/**/*.less', ['build:css:dev']);
gulp.watch('./src/static/**/*', ['copy:static']);
gulp.watch('./src/images/**/*', ['build:img']);
});
It works fine with gulp clean
but not gulp build
. Also, no error if I do gulp clean && gulp build
.
I get the same issue too even when returning the stream, I get it with all the gulp clean type plugins I have tried actually, but not with any grunt ones
+1 to getting this suddenly. Maybe a change in the way gulp operates?
bump
I got this error while running
gulp clean
task.