You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Gulp rundev任务致Node进程挂起,寻求排查解决方法

Gulp rundev Task Hangs Indefinitely on Windows 10 (Node v8.9.4, Gulp v3.9.1)

Problem Overview

I’m stuck with a frustrating issue where running the rundev Gulp task completely locks up the Node/Gulp process—so bad that Git Bash becomes unresponsive, Task Manager can’t kill the process, and I have to restart my computer to recover. The project was untouched for a month and worked flawlessly before this started.

My setup details:

  • Windows 10
  • Node v8.9.4
  • Gulp v3.9.1
  • Brackets editor + Git Bash terminal

When I run gulp rundev in Git Bash, the initial output looks normal, but the clean task never marks as finished, files aren’t served correctly, and the Git Bash window becomes unmanageable (clicking exit, Alt+F4, or using Task Manager all fail). I’ve already tried toggling devMode, closing all background apps, and running Git Bash as admin—none of these fixed the issue.

Relevant Code & Execution Output

Gulpfile.js

const gulp = require("gulp"); 
const concat = require("gulp-concat"); 
const uglify = require("gulp-uglify"); 
const uglifycss = require("gulp-uglifycss"); 
const del = require("del"); 
const sass = require('gulp-sass'); 
const streamqueue = require('streamqueue'); 
const gzip = require("gulp-gzip"); 
const compression = require("compression"); 
const browserSync = require("browser-sync").create(); 
const scripts = require("./scripts"); 
const styles = require("./styles"); 

var devMode = false; 

gulp.task("html", function() { 
  gulp.src("./src/html/**/*.html") 
    .pipe(gulp.dest("./dist/")) 
    /*.pipe(gzip({extension: 'gz'})) 
    .pipe(gulp.dest("./dist/"))*/ 
    .pipe(browserSync.reload({ stream: true })); 
}); 

gulp.task("css", function() { 
  var cssRaw = gulp.src(styles["css"]) 
    .pipe(uglifycss()); 
  var cssFromSass = gulp.src(styles["scss"]) 
    .pipe(sass({outputStyle: 'compressed'})); 
  return streamqueue({objectMode: true}, cssFromSass, cssRaw) 
    .pipe(concat("allStyles.min.css")) 
    .pipe(gulp.dest("./dist/css")) 
    /*.pipe(gzip({extension: 'gz'})) 
    .pipe(gulp.dest("./dist/css"))*/ 
    .pipe(browserSync.reload({ stream: true })); 
}); 

gulp.task("js", function() { 
  var jsMin = gulp.src(scripts["min"]); 
  var jsOther = gulp.src(scripts["other"]) 
    .pipe(uglify()); 
  return streamqueue({objectMode: true}, jsMin, jsOther) 
    .pipe(concat("allScripts.min.js")) 
    .pipe(gulp.dest("./dist/js")) 
    /*.pipe(gzip({extension: 'gz'})) 
    .pipe(gulp.dest("./dist/js"))*/ 
    .pipe(browserSync.reload({ stream: true })); 
}); 

gulp.task("fonts", function() { 
  gulp.src(["./src/fonts/**/*.eot", "./src/fonts/**/*.svg", "./src/fonts/**/*.ttf", "./src/fonts/**/*.woff", "./src/fonts/**/*.woff2"]) 
    .pipe(gulp.dest("./dist/fonts")) 
    .pipe(browserSync.reload({ stream: true })); 
}); 

gulp.task("images", function() { 
  gulp.src(["./src/images/**/*.*"]) 
    .pipe(gulp.dest("./dist/images")) 
    .pipe(browserSync.reload({ stream: true })); 
}); 

gulp.task("sounds", function() { 
  gulp.src(["./src/sounds/**/*.*"]) 
    .pipe(gulp.dest("./dist/sounds")) 
    .pipe(browserSync.reload({ stream: true })); 
}); 

gulp.task("clean", function() { 
  return del('./dist/**', {read: false}); 
}); 

gulp.task("build", ['clean'], function() { 
  gulp.start(["css", "js", "html", "fonts", "images", "sounds"]); 
}); 

gulp.task("browser-sync", function() { 
  browserSync.init(null, { 
    open: false, 
    server: { 
      baseDir: "dist", 
      middleware: compression() 
    }/*, httpModule: 'http2', https: true*/ 
  }); 
}); 

gulp.task("rundev", function() { 
  devMode = true; 
  gulp.start(["build", "browser-sync"]); 
  gulp.watch(["./src/css/**/*.css", "./src/css/**/*.scss"], ["css"]); 
  gulp.watch(["./src/js/**/*.js"], ["js"]); 
  gulp.watch(["./src/html/**/*.html"], ["html"]); 
  gulp.watch(["./src/fonts/**/*.*"], ["fonts"]); 
});

Execution Output

MyName@MyComputer MINGW64 ~ $ cd Documents/GitHub/PoeFilterEditor
MyName@MyComputer MINGW64 ~/Documents/GitHub/PoeFilterEditor (Development) $ gulp rundev
[12:11:27] Using gulpfile ~\Documents\GitHub\PoeFilterEditor\gulpfile.js
[12:11:27] Starting 'rundev'...
[12:11:27] Starting 'clean'...
[12:11:27] Starting 'browser-sync'...
[12:11:27] Finished 'browser-sync' after 114 ms
[12:11:28] Finished 'rundev' after 816 ms
[Browsersync] Access URLs:
 --------------------------------------
       Local: http://localhost:3000
    External: http://192.168.1.142:3000
 --------------------------------------
          UI: http://localhost:3001
 UI External: http://192.168.1.142:3001
 --------------------------------------
[Browsersync] Serving files from: dist

Troubleshooting & Fixes

Let’s break down the most likely causes and actionable fixes for your setup:

1. Fix build Task Async Control (Critical!)

Your build task uses gulp.start()—a deprecated method in Gulp 3.x that creates race conditions. Gulp can’t track when the task finishes, leading to orphaned processes that hang. Update it to use a callback to signal completion:

gulp.task("build", ['clean'], function(done) {
  gulp.start(["css", "js", "html", "fonts", "images", "sounds"], done);
});

The done callback tells Gulp exactly when the build task is fully completed, preventing process hangs.

2. Ensure All Tasks Return Streams

Tasks like html, fonts, images, and sounds don’t return their streams—Gulp can’t track when they finish, which contributes to hangs. Add the return keyword to each:

// Example: Updated html task
gulp.task("html", function() { 
  return gulp.src("./src/html/**/*.html") 
    .pipe(gulp.dest("./dist/")) 
    .pipe(browserSync.reload({ stream: true })); 
});

Repeat this for fonts, images, and sounds tasks.

3. Verify del Package Compatibility

Your clean task uses del, which may have version conflicts with Node v8.9.4. Reinstall a compatible version:

npm uninstall del && npm install del@4.1.1

Version 4.1.1 is known to work smoothly with Node 8.x on Windows.

4. Temporarily Disable Compression Middleware

The compression middleware in BrowserSync can cause deadlocks on Windows. Test removing it:

gulp.task("browser-sync", function() { 
  browserSync.init(null, { 
    open: false, 
    server: { 
      baseDir: "dist"
      // Remove middleware: compression() for testing
    } 
  }); 
});

If the hang stops, either keep it disabled or update compression to a compatible version.

5. Reinstall Corrupted Node Modules

After a month of inactivity, node modules can get corrupted. Reset them:

rm -rf node_modules
npm cache clean --force
npm install

6. Test in Command Prompt Instead of Git Bash

Git Bash on Windows sometimes has process-handling issues with Node tools. Try running gulp rundev in a regular administrator Command Prompt to rule out terminal-specific bugs.

Final Notes

The most impactful fixes here are fixing async control in the build task and ensuring all tasks return streams—these eliminate the race conditions that are almost certainly causing the hang. Combine these with verifying package compatibility, and you should resolve the issue without needing to restart your computer again.

内容的提问来源于stack exchange,提问作者Joshua Olufs

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 04:18:58