【问题标题】:Why am I getting this error? dest.on is not a function - using gulp-file-include为什么我会收到此错误? dest.on 不是一个函数 - 使用 gulp-file-include
【发布时间】:2016-02-27 21:38:07
【问题描述】:

我收到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('./'));
});

【问题讨论】:

    标签: javascript node.js gulp


    【解决方案1】:

    这一行:

    .pipe(fileinclude)
    

    应该是这样的:

    .pipe(fileinclude())
    

    【讨论】:

    • 非常感谢你,我不敢相信我错过了,哈哈。你知道为什么当我尝试使用 path.join(paths.templates, '*.tpl.html) 它会给出错误 path is undefined
    • 你可能忘记了var path = require('path')
    • 老兄,非常感谢你,我还在学习,但慢慢让一切都像魅力一样运作。祝你有美好的一天✌
    猜你喜欢
    • 2016-11-10
    • 1970-01-01
    • 2011-01-03
    • 2016-02-14
    • 2019-10-14
    • 2023-01-24
    • 2015-07-17
    • 2018-06-22
    • 2016-01-01
    相关资源
    最近更新 更多