简体   繁体   English

无法使用CTRL + C停止吞噬

[英]Can't stop gulp with CTRL+C

I am running a project with gulp and I get this in the terminal: 我正在用gulp运行一个项目,并在终端中得到了这个:

crsjopgp6444:promo-llove-your-app-2 berretan$ gulp
[14:14:39] Using gulpfile ~/Documents/Projects/promo-llove-your-app-2/gulpfile.js
[14:14:39] Starting 'assemble'...
[14:14:39] Starting 'sass'...
[14:14:40] Starting 'fonts'...
[14:14:40] Starting 'notify:server'...
[14:14:40] Finished 'fonts' after 197 ms
[14:14:41] gulp-notify: [Gulp notification] Server ready!
[14:14:41] Finished 'notify:server' after 244 ms
[14:14:41] Finished 'assemble' after 2.04 s

when I try to stop the project with CTRL+C isn't allowing me, it's just don't do anything, I have to close the tab and open it in a new one. 当我尝试使用CTRL + C停止该项目不允许我执行此操作时,它只是什么都不做,我必须关闭该选项卡并在一个新的选项卡中将其打开。

And in the browser I can't see anything in the port 9000 which is the one I chose, all I see is this: 在浏览器中,我选择的端口9000中看不到任何东西,我看到的是:

This site can't be reached 无法访问该网站

localhost refused to connect. 本地主机拒绝连接。

Search Google for localhost 9000 在Google中搜索localhost 9000

I am using El Capitan with Node 5.5.0. 我将El Capitan与Node 5.5.0一起使用。

Any suggestions? 有什么建议么?

Although an old question, it still pops up in Google. 尽管是一个老问题,它仍然在Google中弹出。 Here is what ultimately worked for me when using nodemon: 这是使用nodemon时最终为我工作的内容:

var monitor = $.nodemon(...)
// Make sure we can exit on Ctrl+C
process.once('SIGINT', function() {
monitor.once('exit', function() {
      console.log('Closing gulp');
      process.exit();
    });
});
monitor.once('quit', function() {
    console.log('Closing gulp');
    process.exit();
});

Got it from here . 这里得到它。

If you are not using nodemon, this might work as well: 如果您不使用nodemon, 可能也可以使用:

process.on('SIGINT', function() {
  setTimeout(function() {
    process.exit(1);
  }, 500);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM