我试图为未来的项目设置我的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)"
我的代码:
// 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)
P.s:我检查了我的目录正确,所以,我相信,gulp没有问题找到文件P. p. s:我的目录路径可能看起来混乱和滑稽xD
1条答案
按热度按时间w6mmgewl1#
更改此行:
至
你可能被
在文档中,gulp.src签名
但是,签名中的
[]
只是表示该参数是 optional,选项实际上并没有放在括号中,所以options
只是一个{}
对象。