LANGUAGE/!$%!% ERROR NOTE 2019. 6. 24. 05:09

Gulp (걸프)

1. Error - 오류

Error: File not found with singular glob: D:/dev_by_sj/workspaces/sj-js/keyman/dist/js (if this was purposeful, use `allowEmpty` option)

2. Problem - 문제

3에서 4로 버전업이 되면서, 꼭 명시해야할 규칙이 생겼다.

3. Solved - 해결

src()에 두번째 인자로 옵션을 넣어주자! {allowEmpty: true}

  • BEFORE

    /** clean **/
    gulp.task('clean-js', function(){
      return gulp.src(paths.dest.js).pipe(clean());
    });
    gulp.task('clean-css', function(){
      return gulp.src(paths.dest.css).pipe(clean());
    });
    gulp.task('clean-html', function(){
      return gulp.src(paths.dest.html).pipe(clean());
    });
    gulp.task('clean-res', function(){
      return gulp.src(paths.dest.res).pipe(clean());
    });
  • AFTER

    /** clean **/
    gulp.task('clean-js', function(){
      return gulp.src(paths.dest.js, {allowEmpty:true}).pipe(clean());
    });
    gulp.task('clean-css', function(){
      return gulp.src(paths.dest.css, {allowEmpty:true}).pipe(clean());
    });
    gulp.task('clean-html', function(){
      return gulp.src(paths.dest.html, {allowEmpty:true}).pipe(clean());
    });
    gulp.task('clean-res', function(){
      return gulp.src(paths.dest.res, {allowEmpty:true}).pipe(clean());
    });
  • 내가 해결했던 이력을 Diff해서 보여드리자면 이렇다. Example)

Reference - 참조

Did gulp.src allowEmpty default change in Gulp 4?: https://github.com/gulpjs/gulp/issues/2282
src(): https://gulpjs.com/docs/en/api/src#errors