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

91e*_*ahz 33 javascript node.js gulp

我得到一个错误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('./'));
});
Run Code Online (Sandbox Code Playgroud)

Sve*_*ung 54

这一行:

.pipe(fileinclude)
Run Code Online (Sandbox Code Playgroud)

应该是这样的:

.pipe(fileinclude())
Run Code Online (Sandbox Code Playgroud)

  • 老兄非常感谢你,我还在学习,但慢慢地把事情变得像魅力一样.祝你有个美好的一天 (3认同)
  • 您可能忘记了`var path = require('path')`。 (2认同)