Node回退至6后Gulp报TypeError: dest.on is not a function问题求助
Hey there! Let's break down what's causing this error and how to fix it. That TypeError: dest.on is not a function is almost always a sign of a syntax mistake in your Gulp task piping—and I spotted exactly where the issue is in your gulpfile.js.
The Root Cause
Looking at your styles and BootstrapStyle tasks, you're missing a closing parenthesis when calling postcss(). This breaks the pipe chain entirely, so Gulp can't recognize the proper stream object when it gets to .pipe(gulp.dest()), hence the confusing error.
Here's the problematic snippet from your styles task:
.pipe(postcss([autoprefixer()]) //.pipe(minifycss()) .pipe(gulp.dest(STYLE_PATH))
Notice how postcss([autoprefixer()]) doesn't have a closing )? The exact same mistake appears in your BootstrapStyle task too.
The Fix
Add the missing closing parenthesis to both tasks to restore the proper pipe chain:
Corrected styles Task Segment:
.pipe(postcss([autoprefixer()])) // Added closing ) here //.pipe(minifycss()) .pipe(gulp.dest(STYLE_PATH))
Corrected BootstrapStyle Task Segment:
.pipe(postcss([autoprefixer()])) // Added closing ) here .pipe(gulp.dest(STYLE_PATH))
Why Did This Pop Up After Rolling Back Node?
Node.js 6 and 8 handle syntax edge cases differently—your code might have slipped by with Node 8 (or the dependency versions you had at the time), but Node 6 is stricter about unclosed parentheses. Alternatively, the older versions of Gulp and related packages you're using now catch this error more explicitly. Either way, the syntax mistake was present all along, it just became visible after the rollback.
Additional Steps to Ensure Full Functionality
- After fixing the syntax, delete your
node_modulesfolder to clear any potentially corrupted dependencies from the version upgrade/rollback:rm -rf node_modules - Reinstall all dependencies cleanly:
npm install - Run your Gulp tasks again—this should resolve the
dest.on is not a functionerror completely.
内容的提问来源于stack exchange,提问作者Shejan

