Javascript 为什么我收到这个错误?dest.on 不是函数 - 使用 gulp-file-include

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35675762/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 18:06:30  来源:igfitidea点击:

why am i getting this error? dest.on is not a function - using gulp-file-include

javascriptnode.jsgulp

提问by 91eahz

I am getting an Error of TypeError: dest.on is not a function. When running this task, I can't figure out what could be wrong.

我收到一个错误TypeError: dest.on is not a function。运行此任务时,我无法弄清楚可能出了什么问题。

var fileinclude = require('gulp-file-include');
var rename = require('gulp-rename');

var paths = {
  templates : './templates/'
}

//file include: grab partials from templates and render out html files

gulp.task('fileinclude', function() {

return gulp.src(paths.templates + '*.tpl.html')
 .pipe(fileinclude)
 .pipe(rename({
  extname: ""
 }))
.pipe(rename({
  extname: ".html"
 }))
.pipe(gulp.dest('./'));
});

回答by Sven Schoenung

This line:

这一行:

.pipe(fileinclude)

Should be this:

应该是这样的:

.pipe(fileinclude())