search

Home  >  Q&A  >  body text

javascript - The port is occupied when restarting the express server using gulp-nodemon


// 定义web服务模块,增加浏览器同步浏览
gulp.task('browser-sync', ['nodemon'], function () {
    console.log("自动自行刷新-------------------------");
  browsersync.init(null, {
    proxy: 'http://localhost:3000',
    browser: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" ,//在谷歌下面打开
    notify: false,
    port: 3001,
    files: [dist.root+"**/*"]
  });
  
});


gulp.task('nodemon', function (cb) {
  var called = false;

  return nodemon({
    script: 'bin/www'  
  }).on('start', function () {
    if (!called) {
      cb();
      called = true;
    }
  });
});

How to use gulp-nodemon internal deletion to restart the express server

漂亮男人漂亮男人2783 days ago1204

reply all(1)I'll reply

  • 仅有的幸福

    仅有的幸福2017-06-14 10:53:53

    Nodemon itself can monitor js file changes and automatically restart the nodejs service. nodemon only needs to be started once.

    browser-sync task, no need to start nodemon every time.

    reply
    0
  • Cancelreply