Gulp 4 ReferenceError: merge is not defined

Gulp 4 ReferenceError: merge is not defined

在 VS 2019 中,当我尝试 Publish 到文件夹 Gulp 失败并显示 ReferenceError: merge is not defined

gulpfile.js

/// <binding AfterBuild='default' />
var gulp = require('gulp');
var uglify = require("gulp-uglify");
var concat = require("gulp-concat");

gulp.task('minify', function () {
    return gulp.src("wwwroot/js/**/*.js")
        .pipe(uglify())
        .pipe(concat("dutchtreat.min.js"))
        .pipe(gulp.dest("wwwroot/dist"));
}); 

var nodeModules = {
  "bootstrap": { "dist/**/*": "" },
  "font-awesome": { "**/*": "" },
  "jquery": { "dist/*": "" },
  "jquery-validation": { "dist/*": "" },
  "jquery-validation-unobstrusive": { "dist/*": "" }  };

gulp.task("node_modules", function () {
let streams = [];

for (var module in nodeModules) {
    console.log("Prepping Scripts for: " + module);
    for (var itemProp in nodeModules[module]) {
        streams.push(gulp.src("node_modules/" + module + "/" + itemProp)
            .pipe(gulp.dest("wwwroot/lib" + module + "/" + nodeModules[module][itemProp])));
    }
}
return merge(streams);
}); 

gulp.task('default', gulp.series("node_modules", "minify")); 

package.json "devDependencies"

"gulp": "4.0.2",
"gulp-uglify": "3.0.2",
"gulp-concat": "2.6.1",
"merge-stream": "2.0.0",
"merge": "1.2.1"

依赖项中加载了所有 5 个文件 | npm 文件夹。

为什么找不到merge?此语法对 Gulp 4 正确吗?

你需要 require merge 才能像使用其他所有东西一样使用它。

 var merge = require(“merge-stream”);

我想我通常使用 gulp-merge,但我相信 merge-stream 也能正常工作。