Gulp encountered pit

gulp报错The following tasks did not complete

 

code show as below:

Copy the code
// reference gulp module 
const = gulp the require ( 'gulp'); 
// use gulp.task () Setup Task 
gulp.task ( 'First', () => { 
    the console.log ( 'first task executed gulp '); 

    files // // to process the output file processed to the next directory dist 
    gulp.src (' ./ the src / CSS / base.css ') 
        .pipe (gulp.dest (' ./ dist / CSS ')); 

});
Copy the code

 

Error:

[01:26:16] The following tasks did not complete: first
[01:26:16] Did you forget to signal async completion?

 

 

the reason:

This is a problem when using the task, the callback function uses the anonymous function gulp4.0 version brings, gulpgulp no longer support synchronization task

There are many solutions specific reference  https://www.gulpjs.com.cn/docs/getting-started/async-completion/

Relatively simple method is to add callback, to indicate the completion of the function

I.e., change the code to:

 

Copy the code
// reference gulp module 
const = gulp the require ( 'gulp'); 
// use gulp.task () Setup Task 
gulp.task ( 'First', (CB) => { 
    ( 'first task execution gulp console.log a '); 

    files // // to process the output file processed to dist directory 
    gulp.src (' ./ the src / CSS / base.css ') 
        .pipe (gulp.dest (' ./ dist / CSS ')); 
    CB (); 
});
Copy the code

  

 

Results are as follows:

PS C:\Users\User\Desktop\nodejs\gulp-demo> gulp first [01:34:28] Using gulpfile ~\Desktop\nodejs\gulp-demo\gulpfile.js
[01:34:28] Starting 'first'...
第一个gulp任务执行了
[01:34:28] Finished 'first' after 9.06 ms
PS C:\Users\User\Desktop\nodejs\gulp-demo>

 

 

Excerpt: https://www.cnblogs.com/sphjy/p/11538264.html

code show as below:

Copy the code
// reference gulp module 
const = gulp the require ( 'gulp'); 
// use gulp.task () Setup Task 
gulp.task ( 'First', () => { 
    the console.log ( 'first task executed gulp '); 

    files // // to process the output file processed to the next directory dist 
    gulp.src (' ./ the src / CSS / base.css ') 
        .pipe (gulp.dest (' ./ dist / CSS ')); 

});
Copy the code

 

Error:

[01:26:16] The following tasks did not complete: first
[01:26:16] Did you forget to signal async completion?

 

 

the reason:

This is a problem when using the task, the callback function uses the anonymous function gulp4.0 version brings, gulpgulp no longer support synchronization task

There are many solutions specific reference  https://www.gulpjs.com.cn/docs/getting-started/async-completion/

Relatively simple method is to add callback, to indicate the completion of the function

I.e., change the code to:

 

Copy the code
// reference gulp module 
const = gulp the require ( 'gulp'); 
// use gulp.task () Setup Task 
gulp.task ( 'First', (CB) => { 
    ( 'first task execution gulp console.log a '); 

    files // // to process the output file processed to dist directory 
    gulp.src (' ./ the src / CSS / base.css ') 
        .pipe (gulp.dest (' ./ dist / CSS ')); 
    CB (); 
});
Copy the code

  

 

Results are as follows:

PS C:\Users\User\Desktop\nodejs\gulp-demo> gulp first [01:34:28] Using gulpfile ~\Desktop\nodejs\gulp-demo\gulpfile.js
[01:34:28] Starting 'first'...
第一个gulp任务执行了
[01:34:28] Finished 'first' after 9.06 ms
PS C:\Users\User\Desktop\nodejs\gulp-demo>

 

 

Excerpt: https://www.cnblogs.com/sphjy/p/11538264.html

Guess you like

Origin www.cnblogs.com/by-DSL/p/12517817.html