简体   繁体   English

处理 gulp 文件时我无法摆脱这个问题 TypeError: Cannot read properties of undefined (reading 'pipe')

[英]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.

相关问题 TypeError: Cannot read properties of undefined (reading 'strEmail') 我该如何解决这个问题? - TypeError: Cannot read properties of undefined (reading 'strEmail') How can I solve this problem? 错误类型错误:无法读取未定义的属性(读取“管道”) - ERROR TypeError: Cannot read properties of undefined (reading 'pipe') 获取 TypeError:在发送 ajax 请求(Angular 12)时无法读取未定义的属性(读取“管道”) - Getting TypeError: Cannot read properties of undefined (reading 'pipe') while sending ajax request (Angular 12) 尝试显示 API 响应时无法消除此错误“无法读取未定义的属性(读取‘每个’)”- ReactJs - Can't get rid of this error "Cannot read properties of undefined (reading 'each')" when trying to display API response - ReactJs 类型错误:无法读取未定义的属性(读取“源”)可能存在异步问题 - TypeError: Cannot read properties of undefined (reading 'source') possible problem with async Uncaught TypeError: Cannot read properties of undefined (reading '0') 矩阵转置问题 - Uncaught TypeError: Cannot read properties of undefined (reading '0') matrix transpose problem 无法读取未定义的属性(读取“当前”)我无法从数组中获取 slug - Cannot read properties of undefined (reading 'current') I can't get slug from array 'Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'writeFile')' 尝试使用 REACT 写入文件时出错 - 'Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'writeFile')' error while trying to write to a file with REACT 代码停止工作,没有改变任何事情。 错误是:类型错误:无法读取未定义的属性(读取“命令”) - Code stopped working, didn't change a thing. Error is: TypeError: Cannot read properties of undefined (reading 'commands') TypeError:无法读取未定义的属性(读取'get')帮助我 - TypeError: Cannot read properties of undefined (reading 'get') help me
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM