【问题标题】:gulp dest.on is not a function when replacing替换时 gulp dest.on 不是函数
【发布时间】:2018-11-09 12:08:23
【问题描述】:

我正在尝试替换已编译的 html 文件中的字符。

function watcherpages() {
return gulp.src(['src/pages/**/*.html', '!src/pages/archive/**/*.html'])
    .pipe(panini({
        root: 'src/pages',
        layouts: 'src/layouts',
        partials: 'src/partials',
        helpers: 'src/helpers',
        data: 'src/data'
    }))
    .pipe(inky())
    .pipe(gulp.dest('watch'))
    .pipe($.replace, '&lt;', '<');

}

但最后一行代码给了我以下错误

14:00:01] TypeError: dest.on is not a function
at Pumpify.Readable.pipe (\node_modules\readable-stream\lib\_stream_readable.js:564:8)
at watcherpages (\gulpfile.js:84:10)
at bound (domain.js:301:14)
at runBound (domain.js:314:12)
at asyncRunner (\node_modules\async-done\index.js:55:18)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)

【问题讨论】:

  • 你不需要像 .pipe($.replace( '<', '
  • @Mark 你可以单独发表评论,以便我接受。非常感谢,括号不见了,你拯救了我的一天啊哈哈

标签: javascript html replace compiler-errors gulp


【解决方案1】:

在下面的行中,您缺少一些括号:

.pipe($.replace, '&lt;', '<');  

应该是

.pipe($.replace( '&lt;', '<'));

[您最终需要稍后在管道中保存这些更改]

【讨论】:

    猜你喜欢
    • 2016-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-12
    • 2020-04-28
    • 2016-02-14
    • 1970-01-01
    相关资源
    最近更新 更多