[英]I can't get rid of this problem while working with gulp file TypeError: Cannot read properties of undefined (reading 'pipe')
I am trying to setup my gulpfile for future projects and on the firt stage bumped into a problem that accompanies me no matter what do I do with my code: Here it is :我正在尝试为未来的项目设置我的 gulpfile,并且在第一阶段遇到了一个伴随我的问题,无论我对我的代码做什么:这里是:
"TypeError: Cannot read properties of undefined (reading 'pipe')
at pipe (D:\HTML\NodeJs\Gulp\src\node_modules\pump\index.js:56:15)
at Array.reduce (D:\HTML\NodeJs\Gulp\src\node_modules\ometa\lib.js:101:9)
at pump (D:\HTML\NodeJs\Gulp\src\node_modules\pump\index.js:79:11)
at Pumpify.setPipeline (D:\HTML\NodeJs\Gulp\src\node_modules\pumpify\index.js:39:5)
at new Pumpify (D:\HTML\NodeJs\Gulp\src\node_modules\pumpify\index.js:15:30)
at Function.Pumpify [as obj] (D:\HTML\NodeJs\Gulp\src\node_modules\pumpify\index.js:13:44)
at globStream (D:\HTML\NodeJs\Gulp\src\node_modules\glob-stream\index.js:73:18)
at Gulp.src (D:\HTML\NodeJs\Gulp\src\node_modules\vinyl-fs\lib\src\index.js:24:5)
at operationsWithJsFiles (D:\HTML\NodeJs\Gulp\src\gulpfile.js:23:12)
at bound (node:domain:421:15)"
My code:我的代码:
// Importing gulp modules
let {Gulp,parallel,dest,series,src, tree} = require('gulp')
let cleanCss = require('clean-css')
let uglify = require('gulp-uglify')
let scss = require('gulp-scss')(require('scss'))
let concat = require('gulp-concat')
let autoprefixer = require('gulp-autoprefixer')
let path = require('path')
let rename = require('gulp-rename')
// Minimizing js files
function operationsWithJsFiles(){
return src('js/*.js',[{allowEmpty:true}])
.pipe(uglify())
.pipe(rename({
extname:'.min.js'
}))
.pipe(concat('AllJs.js'))
.pipe(dest('../Dist'))
}
// Minimizing scss files
function operationsWithScssFiles(){
return src('scss/*.scss')
.pipe(scss())
.pipe(autoprefixer({
cascade:false
}))
.pipe(rename({
extname:'.min.css'
}))
.pipe(concat('AllCss.css'))
.pipe(dest('../Dist'))
}
exports.default = parallel(operationsWithJsFiles,operationsWithScssFiles)
Ps: I checked my directories properly, so, I believe, gulp has no issues with finding files Pps: My directory path may look confusing and hilarious xD Ps:我正确检查了我的目录,所以,我相信,gulp 查找文件没有问题 Pps:我的目录路径可能看起来令人困惑和搞笑 xD
Change this line:更改此行:
return src('js/*.js',[{allowEmpty:true}])
to至
return src('js/*.js',{allowEmpty:true})
You may have been confused by你可能已经被迷惑了
src(globs, [options])
in the documentation, gulp.src signature在文档中, gulp.src 签名
But the enclosing []
in the signature only indicate that that parameter is optional .但是签名中包含的
[]
仅表明该参数是可选的。 The options don't actually go into the brackets.这些选项实际上并没有放在括号中。 So
options
is just a {}
object.所以
options
只是一个{}
对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.