Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

281
Vistas
How can I signal NodeJS (Gulp Specifically) with a callback when Express server starts?

I'm trying to create a gulp workflow that includes nodemon, typescript, and browsersync. When I try to reload the browser with browsersync the browser reloads before the express server has had a chance to finish creating routes, etc. So in the end I have to reload the browser manually anyway (f5). I have tried to use gulp-nodemon events, gulp.watch(), and gulp-nodemon tasks in the config. All to no avail. I'm thinking that if it's possible, I can notify nodemon that Express is ready and manually trigger the page load or maybe even notify browsersync in the browser from express to reload the page.

for simplicity here is a small version of my gulpfile:

const browser = require('browser-sync');

gulp.task('typescript', function(){
  return gulp.src(config.src + '/**/*.ts')
    .pipe(tsProject())
    .pipe(gulp.dest(config.dist));
});

gulp.task('server', function (done) {

    // Create nodemon instance
    $.nodemon({
        script: config.dist + '/app.js',
        watch: config.src + '/**/*',
        ext: '*.*',
        env: {
            'NODE_ENV': 'development'
        },
        tasks: ['typescript'] 
    }).on('start',function(done){
        browser.reload();
    });
    done();
});

gulp.task('sync', function (done) {
     // Init browser-sync
    browser.init({
        port: 3000,
        proxy: 'localhost:8000'
    });
    done();
};

gulp.task('default', gulp.series(clean, 'typescript', 'server', 'sync'));

For the most part everything works. TypeScript transpiles, Nodemon starts serving the Express app, and BrowserSync launches successfully. On changes the Typescript transpiles, Nodemon restarts the Express app, and BrowserSync reloads. The problem is BrowserSync reloads before Express has a chance to start listening for connections. Any suggestions?

about 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda