<i id='HKcNu'><tr id='HKcNu'><dt id='HKcNu'><q id='HKcNu'><span id='HKcNu'><b id='HKcNu'><form id='HKcNu'><ins id='HKcNu'></ins><ul id='HKcNu'></ul><sub id='HKcNu'></sub></form><legend id='HKcNu'></legend><bdo id='HKcNu'><pre id='HKcNu'><center id='HKcNu'></center></pre></bdo></b><th id='HKcNu'></th></span></q></dt></tr></i><div id='HKcNu'><tfoot id='HKcNu'></tfoot><dl id='HKcNu'><fieldset id='HKcNu'></fieldset></dl></div>
    <legend id='HKcNu'><style id='HKcNu'><dir id='HKcNu'><q id='HKcNu'></q></dir></style></legend>

      <bdo id='HKcNu'></bdo><ul id='HKcNu'></ul>

  • <tfoot id='HKcNu'></tfoot>

        <small id='HKcNu'></small><noframes id='HKcNu'>

        使用 gulp-nodemon &amp; 时无法使用 Ctrl+C 停止 G

        时间:2023-05-29
        <i id='0ravl'><tr id='0ravl'><dt id='0ravl'><q id='0ravl'><span id='0ravl'><b id='0ravl'><form id='0ravl'><ins id='0ravl'></ins><ul id='0ravl'></ul><sub id='0ravl'></sub></form><legend id='0ravl'></legend><bdo id='0ravl'><pre id='0ravl'><center id='0ravl'></center></pre></bdo></b><th id='0ravl'></th></span></q></dt></tr></i><div id='0ravl'><tfoot id='0ravl'></tfoot><dl id='0ravl'><fieldset id='0ravl'></fieldset></dl></div>

          • <legend id='0ravl'><style id='0ravl'><dir id='0ravl'><q id='0ravl'></q></dir></style></legend>
          • <small id='0ravl'></small><noframes id='0ravl'>

              1. <tfoot id='0ravl'></tfoot>
                  <tbody id='0ravl'></tbody>
                • <bdo id='0ravl'></bdo><ul id='0ravl'></ul>
                  本文介绍了使用 gulp-nodemon &amp; 时无法使用 Ctrl+C 停止 Gulpgulp.watch 一起看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  当我在没有 node 任务的情况下运行 gulp 时,它可以正常工作并按预期处理客户端文件,如果我运行 gulp node 它会按预期处理服务器文件.但是,如果我同时运行 gulp 它会按预期同时处理客户端和服务器文件,但是,它不会让我通过按Ctrl + C"退出(在 Windows 10 和 Mac El Capitan 上尝试过)).我在这里做错了吗?

                  When I run gulp without the node task, it works fine and processes client file as expected, If I run gulp node it processes server file as expected. However if I run both gulp it processes both client and server file as expected, however, it won't let me quit by pressing 'Ctrl + C' (Tried it on windows 10 & Mac El Capitan). Is there something I'm doing wrong here?

                  'use strict';
                    var gulp = require('gulp');
                      var connect = require('gulp-connect'); 
                      var browserify = require('browserify'); 
                      var source = require('vinyl-source-stream'); 
                      var nodemon = require('gulp-nodemon');
                  
                      var config = {
                          port: 9005,
                          devBaseUrl: 'http://localhost',
                          paths: {
                              html: './src/*.html',
                              dist: './dist',
                              js: './src/**/*.js',
                              images: './src/images/*',
                              mainJs: './src/main.js',
                              css: [
                                  'node_modules/bootstrap/dist/css/bootstrap.min.css',
                                  'node_modules/bootstrap/dist/css/bootstrap-theme.min.css'
                              ]
                          }
                      };
                  
                  gulp.task('connect', function () {
                      connect.server({
                          root: ['dist'],
                          port: config.port,
                          base: config.devBaseUrl,
                          livereload: true
                      });
                  });
                  
                  
                  gulp.task('html', function () {
                      gulp.src(config.paths.html)
                          .pipe(gulp.dest(config.paths.dist))
                  });
                  
                  gulp.task('js', function () {
                      browserify(config.paths.mainJs)
                          .bundle()
                          .on('error', console.error.bind(console))
                          .pipe(source('bundle.js'))
                          .pipe(gulp.dest(config.paths.dist + '/scripts'))
                          .pipe(connect.reload())
                  
                  });
                  
                  gulp.task('node', function () {
                      nodemon({
                          script: 'server/index.js',
                          ext: 'js',
                          env: {
                              PORT: 8000
                          },
                          ignore: ['node_modules/**','src/**','dist/**']
                      })
                      .on('restart', function () {
                          console.log('Restarting node server...');
                      })
                  });
                  
                  gulp.task('watch', function () {
                      gulp.watch(config.paths.js, ['js']);
                  });
                  
                  gulp.task('default', ['html', 'js', 'connect', 'node', 'watch']);
                  

                  推荐答案

                  我之前遇到过类似的问题,这就是您要找的:

                  I had a similar issue before this is what you're looking for :

                  process.on('SIGINT', function() {
                    setTimeout(function() {
                      gutil.log(gutil.colors.red('Successfully closed ' + process.pid));
                      process.exit(1);
                    }, 500);
                  });
                  

                  只需将此代码添加到您的 gulp 文件中即可.它将监视 ctrl + C 并正确终止该过程.如果需要,您也可以在超时中添加一些其他代码.

                  Just add this code to your gulp file. It will watch the ctrl + C and properly terminate the process. You can put some other code in the timeout also if desired.

                  这篇关于使用 gulp-nodemon &amp; 时无法使用 Ctrl+C 停止 Gulpgulp.watch 一起看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:无法让 gulp-rev-replace 与 gulp-useref 一起使用 下一篇:如何在 Visual Studio 2017 中禁用 JavaScript 构建错误

                  相关文章

                  最新文章

                  <legend id='e7dWm'><style id='e7dWm'><dir id='e7dWm'><q id='e7dWm'></q></dir></style></legend>
                • <i id='e7dWm'><tr id='e7dWm'><dt id='e7dWm'><q id='e7dWm'><span id='e7dWm'><b id='e7dWm'><form id='e7dWm'><ins id='e7dWm'></ins><ul id='e7dWm'></ul><sub id='e7dWm'></sub></form><legend id='e7dWm'></legend><bdo id='e7dWm'><pre id='e7dWm'><center id='e7dWm'></center></pre></bdo></b><th id='e7dWm'></th></span></q></dt></tr></i><div id='e7dWm'><tfoot id='e7dWm'></tfoot><dl id='e7dWm'><fieldset id='e7dWm'></fieldset></dl></div>
                  • <bdo id='e7dWm'></bdo><ul id='e7dWm'></ul>
                  1. <tfoot id='e7dWm'></tfoot>

                    <small id='e7dWm'></small><noframes id='e7dWm'>