В Gulp возникает ошибка TypeError: Cannot read properties of undefined (reading 'on')
Суть в том, что переделываю common JS gulp на ("type": "module"). При запуске gulp всё вроде бы отрабатывает нормально, но только через некоторое время крашится таск html.js, в котором panini. И я не могу понять, что делать, если добавить plumber, то вылетает Error: Can't pipe to undefined
//файл html.js
import panini from "panini";
export const html = () => {
panini.refresh();
return app.gulp.src(app.path.src.html, {base : app.path.srcPath})
.pipe(panini({
root: app.path.srcPath,
layouts: app.path.srcPath + 'layouts/',
partials: app.path.srcPath + 'partials/',
helpers: app.path.srcPath + 'helpers/',
data: app.path.srcPath + 'data/'
}))
.pipe(app.gulp.dest(app.path.build.html))
.pipe(app.plugins.browserSync.reload({steam : true}));
}
// файл gulpfile.js
import gulp from "gulp";
import { path } from "./gulp/config/path.js";
import { plugins } from "./gulp/config/plugins.js";
global.app = {
path: path,
gulp: gulp,
plugins: plugins,
}
import { serve } from "./gulp/tasks/serve.js"
import { clean } from "./gulp/tasks/clean.js";
import { sass } from "./gulp/tasks/sass.js";
import { html } from "./gulp/tasks/html.js";
import { js } from "./gulp/tasks/js.js";
//import { images } from "./gulp/tasks/images.js"
import { fonts } from "./gulp/tasks/fonts.js";
function watchFiles() {
gulp.watch([path.watch.html], html);
gulp.watch([path.watch.css], sass.cssWatch);
gulp.watch([path.watch.js], js.jsWatch);
//gulp.watch([path.watch.images], images.images);
gulp.watch([path.watch.fonts], fonts);
}
const build = gulp.series(clean, gulp.parallel(html, sass, js, fonts));
const watch = gulp.parallel(build, watchFiles, serve);
gulp.task('default', watch);
файл path.js
import * as nodePath from 'path';
const rootFolder = nodePath.basename(nodePath.resolve());
const distPath = './dist';
const srcPath = './src';
export const path = {
build: {
html: distPath,
js: distPath + "assets/js/",
css: distPath + "assets/css/",
images: distPath + "assets/images/",
fonts: distPath + "assets/fonts/"
},
src: {
html: srcPath + "*.html",
js: srcPath + "assets/js/*.js",
css: srcPath + "assets/scss/*.{scss,sass}",
images: srcPath + "assets/images/**/*.{jpg,png,gif,ico,webp,webmanifest,xml,json}",
svg: srcPath + "assets/images/**/*.svg",
fonts: srcPath + "assets/fonts/**/*.{eot,woff,woff2,ttf,svg}"
},
watch: {
html: srcPath + "**/*.html",
js: srcPath + "assets/js/**/*.js",
css: srcPath + "assets/scss/**/*.{scss,sass}",
images: srcPath + "assets/images/**/*.{jpg,png,svg,gif,ico,webp,webmanifest,xml,json}",
fonts: srcPath + "assets/fonts/**/*.{eot,woff,woff2,ttf,svg}"
},
clean: distPath,
distPath: distPath,
srcPath: srcPath,
rootFolder: rootFolder,
ftp: ``,
}

