7

我正在运行 Express 服务器并使用 browserSync 来监视更改。当我运行时npm start,它会启动一个运行的 gulp 任务:

// Server task
gulp.task('server', function(cb) {

  // We use this `called` variable to make sure
  // the callback is only executed once
  var called = false;

  return nodemon({
    script: 'server.js',
    watch: ['server.js', 'app/**/*.js', 'config/**/*.js']
  })
  .on('start', function onStart() {
    if (!called) {
      cb();
    }
    called = true;
  })
  .on('restart', function onRestart() {

    // Also reload the browsers after a slight delay
    setTimeout(function reload() {
      browserSync.reload({
        stream: false
      });
    }, 500);
  });
});

// BrowserSync
gulp.task('browser-sync', ['server'], function() {
    browserSync.init({

      // All of the following files will be watched
      files: ['public/**/*.*'],

      // Tells BrowserSync on where the express app is running
      proxy: 'http://localhost:3000',
      port: 4000,
      open: false,
      notify: false,
      logPrefix: project.name,
      logConnections: false,
      logLevel: 'silent'
    });
  });

但是,在终端窗口中,它会继续显示以下内容:

GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1428091521010-28291 200 10.482 ms - -
GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1428091521032-28292 200 10.573 ms - -
GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1428091521053-28293 200 8.754 ms - -
GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1428091521082-28294 200 7.013 ms - -
GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1428091521110-28295 200 8.339 ms - -
GET /browser-sync/socket.io/?EIO=3&transport=polling&t=1428091521134-28296 200 12.367 ms 

这是什么原因造成的?我怎样才能解决这个问题?

4

1 回答 1

1

我面临着同样的问题。退出powershellrestarting firefox解决问题。

希望这可以帮助!

于 2015-11-25T00:59:44.733 回答