Aaron Shen
Aaron Shen

Reputation: 8394

gulp clean throw Error: ENOENT, stat exception?

I have following directory structure:

web/
   index.html
   js/
      vendor/
            xxxx/
               x1.js
               x2.js
               x3.js
               ...
   view/
       v1.js
       v2.js

I want to use gulp-clean to delete all files under www folder except index.html. But I got the

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: ENOENT, stat '/Users/xxxx/yyy.js'

Here's the gulp task:

gulp.task('test2', function () {
    'use strict';
    gulp.src(['web/**', '!web/index.html'], {
        read: false
    })
        .pipe(clean({
            force: true
        }));
}); 

What I'm doing wrong here?

Upvotes: 0

Views: 2343

Answers (2)

John Miller
John Miller

Reputation: 1009

I ran into the same issue with gulp-clean. Have you tried del instead? It seems to work as expected.

Upvotes: 1

Albestio
Albestio

Reputation: 114

Try this instead:

gulp.task('test2', function () {
'use strict';
gulp.src(['!web/index.html', 'web/**'], {
    read: false
})
    .pipe(clean({
        force: true
    }));

});

Write your exceptions first ;)

Upvotes: 0

Related Questions