You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found quite a few watch-related issues, unfortunately none helped me with my case. I noticed two problems:
When stopping the task with Control+C the script fails with the following error. If I remove watchFiles or startNodemon/BrowserSync tasks, everything works fine.
[14:09:04] The following tasks did not complete: serve, <parallel>, watchFiles
[14:09:04] Did you forget to signal async completion?
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ serve: `gulp serve`
npm ERR! Exit status 1
After trial and error I figured that if a callback gets passed/invoked in watch files task it would prevent the termination failure, however in approx. ⅓ launches the file watching wouldn't work. Literally. Upon one launch it behaves as expected when changing a file. Upon next launch it wouldn't see changes at all and won't run.
Here's the gulp file:
importBrowserSyncfrom"browser-sync";importdelfrom"del";importgulpfrom"gulp";importchangedfrom"gulp-changed";importnodemonfrom"gulp-nodemon";importtsfrom"gulp-typescript";constbrowserSync=BrowserSync.create();consttsProject=ts.createProject("./tsconfig.json");functioncleanProduct(){returndel(["./product/js","./product/css","./entrypoint"]);}functionbuildJS(){returngulp.src(["./source/ts/**/*.ts","./source/d.ts/**/*.ts"]).pipe(changed("./product/js",{extension: ".js"})).pipe(tsProject()).pipe(gulp.dest("./product/js")).pipe(browserSync.stream());}functionwatchFiles(){gulp.watch("./source/ts/**/*.ts",gulp.series(buildJS));}// This callback setup is needed for correct BrowserSync initialization in case you wonder…functionstartNodemon(cb){letisStarting=false;letserver=nodemon({script: "./product/js/index.js",ignore: "./product/js/**/*Test.js",watch: "./product/js/**/*.js",stdout: false,ext: ""});constfinalize=()=>{if(!isStarting){return;}isStarting=false;cb();};server.on("start",()=>{isStarting=true;setTimeout(finalize,5000);});server.on("stdout",(stdout)=>{process.stdout.write(stdout);// pass the stdout throughif(isStarting){finalize();}});}functionstartBrowserSync(cb){browserSync.init({proxy: "http://localhost:8080",port: 8081,ui: false},cb);}constbuild=gulp.series(cleanProduct,gulp.parallel(buildJS));constserve=gulp.series(build,gulp.parallel(gulp.series(startNodemon,startBrowserSync),watchFiles));exports.default=build;exports.build=build;exports.serve=serve;
I tried removing BrowserSync out of the equation, but it doesn't seem to be making any difference. Is there any special treatment for the module or other workaround to make it work without throwing errors on exit and not using a callback with file watch task?
The text was updated successfully, but these errors were encountered:
Same issue, I included the versions I use. Sad, it's a pain to start node after every changes 😢
[22:59:41] [nodemon] starting `node ./build/server.js`
{"level":30,"time":1585623581312,"pid":25258,"hostname":"","msg":"Server listening at http://127.0.0.1:3000","v":1}
{"level":30,"time":1585623581313,"pid":25258,"hostname":"","msg":"server listening on 3000","v":1}
[22:59:41] The following tasks did not complete: default, serve
[22:59:41] Did you forget to signal async completion?
I found quite a few watch-related issues, unfortunately none helped me with my case. I noticed two problems:
When stopping the task with Control+C the script fails with the following error. If I remove
watchFiles
orstartNodemon/BrowserSync
tasks, everything works fine.After trial and error I figured that if a callback gets passed/invoked in watch files task it would prevent the termination failure, however in approx. ⅓ launches the file watching wouldn't work. Literally. Upon one launch it behaves as expected when changing a file. Upon next launch it wouldn't see changes at all and won't run.
Here's the gulp file:
I tried removing BrowserSync out of the equation, but it doesn't seem to be making any difference. Is there any special treatment for the module or other workaround to make it work without throwing errors on exit and not using a callback with file watch task?
The text was updated successfully, but these errors were encountered: