首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >TypeError: dest.on不是gulp中的函数

TypeError: dest.on不是gulp中的函数
EN

Stack Overflow用户
提问于 2019-01-25 07:53:52
回答 1查看 2.1K关注 0票数 0

当我在我的主题源文件夹中编辑主题.yml文件时,我得到这个错误。当我仅在主文件夹中编辑模板文件夹中的scss或模板.yml文件时,不会出现这种情况。其他有这个错误的人使用了像webpack这样的东西,这是我没有的。copy_theme_files的吞噬任务与其他任务相同,不同的是它没有返回,因为我不知道如何用两个gulp.src函数返回它。

代码语言:javascript
运行
复制
gulp.task('copy_theme_files', function() {
    console.log('[copy_theme_files] Console Log: copy '+paths.themeSrc+' to '+paths.themeDest);
    gulp.src(paths.themeSrc)
        .pipe(gulp.dest(paths.themeDest));
    gulp.src(paths.root + '/*.{png,ico,svg}')
        .pipe(paths.themeDest);
});

Full gulpfile.js https://pastebin.com/NWt2uMwV

错误输出:

代码语言:javascript
运行
复制
[00:37:58] Using gulpfile /var/www/themes.src/mytheme.src/gulpfile.js
[00:37:58] Starting 'watch'...
[00:38:20] Starting 'copy_theme_files'...
[copy_theme_files] Console Log: copy *.{yml,theme,php,png,jpg,gif,svg,ico},.gitkeep to build
[00:38:20] 'copy_theme_files' errored after 23 ms
[00:38:20] TypeError: dest.on is not a function
    at DestroyableTransform.Readable.pipe (/var/www/themes.src/mytheme.src/node_modules/readable-stream/lib/_stream_readable.js:564:8)
    at /var/www/themes.src/mytheme.src/gulpfile.js:122:10
    at taskWrapper (/var/www/themes.src/mytheme.src/node_modules/undertaker/lib/set-task.js:13:15)
    at bound (domain.js:395:14)
    at runBound (domain.js:408:12)
    at asyncRunner (/var/www/themes.src/mytheme.src/node_modules/async-done/index.js:55:18)
    at process._tickCallback (internal/process/next_tick.js:61:11)
[00:38:20] Starting 'copy_includes'...
[copy_includes] Console Log: copy includes/**/*.*,includes/**/.gitkeep to build/includes
[00:38:20] Finished 'copy_includes' after 7.41 ms
[00:38:20] Starting 'copy_build'...
[copy_build] Console Log: copy build/**/*.*,build/**/.gitkeep to ../../web/themes/local/mytheme
[00:38:20] Finished 'copy_build' after 60 ms

其他任务运行正常

代码语言:javascript
运行
复制
[00:41:06] Starting 'copy_templates'...
[copy_templates] Console Log: copy templates/**/*.twig,templates/**/.gitkeep to build/templates
[00:41:08] Finished 'copy_templates' after 1.86 s
[00:41:08] Starting 'copy_build'...
[copy_build] Console Log: copy build/**/*.*,build/**/.gitkeep to ../../web/themes/local/mytheme
[00:41:09] Finished 'copy_build' after 326 ms
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-01-25 08:49:39

您的任务中包含以下内容:

代码语言:javascript
运行
复制
.pipe(paths.themeDest);

你的意思可能是:

代码语言:javascript
运行
复制
.pipe(gulp.dest(paths.themeDest));

对于你的另一个问题,请查看merging two gulp.src streams,了解如何返回:

代码语言:javascript
运行
复制
var merge = require('merge-stream');

gulp.task('copy_theme_files', function() {
    console.log('[copy_theme_files] Console Log: copy '+paths.themeSrc+' to '+paths.themeDest);

    const themesStream = gulp.src(paths.themeSrc)
        .pipe(gulp.dest(paths.themeDest));

    const imagesStream = gulp.src(paths.root + '/*.{png,ico,svg}')
        .pipe(paths.themeDest);

    return merge(themesStream , imagesStream );
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54357132

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档