EEXIST error when trying to overwrite an existing file in Gulp?

You should be able to use gulp.dest which has an option overwrite

options.overwrite Type: Boolean

Default: true

Specify if existing files with the same path should be overwritten or not.


Gulp have overwrite option

gulp.task('bower', () => {
  return gulp.src('input/*.js')
    .pipe(gulp.dest('output/',{overwrite:true})) 
})

another example

const { src, dest } = require('gulp');

function copy() {
  return src('input/*.js')
    .pipe(dest('output/',{overwrite:true}));
}

full documentation https://gulpjs.com/docs/en/api/dest


It will be ok.

gulp.task('bower', () => {
  return gulp.src('app/index.html')
    .pipe(wiredep())
    .pipe(gulp.dest('app')) // Have wiredep operate on the source 
})

gulp.dest() expects a directory. You're passing it a file name.

What happens is that gulp tries to create the directory app/index.html, which it can't since there's already a file with that name.

All you need to do is pass app/ as the destination directory:

gulp.task('bower', () => {
  return gulp.src('app/index.html')
    .pipe(wiredep())
    .pipe(gulp.dest('app/'));
})

Tags:

Gulp