我第一次使用gulp。在我的gulpfile.js中包含
var gulp = require('gulp');
var imagemin = require('gulp-imagemin');
gulp.task('default', function () { console.log('Hello Gulp!') });
gulp.task('imagemin', function() {
var img_src = 'src/images/**/*', img_dest = 'build/images';
gulp.src(img_src)
.pipe(changed(img_dest))
.pipe(imagemin())
.pipe(gulp.dest(img_dest));
});
从我的woking文件夹以$ gulp imagemin运行Git bash时
但它显示以下错误
[11:35:12] Using gulpfile C:\xampp\htdocs\work\gulpfile.js
[11:35:12] Starting 'imagemin'...
[11:35:12] 'imagemin' errored after 10 ms
[11:35:12] ReferenceError: changed is not defined
at Gulp.<anonymous> (C:\xampp\htdocs\work\gulpfile.js:8:10)
at module.exports (C:\xampp\htdocs\work\node_modules\orchestrator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask (C:\xampp\htdocs\work\node_modules\orchestrator\index.js:273:3)
at Gulp.Orchestrator._runStep (C:\xampp\htdocs\work\node_modules\orchestrator\index.js:214:10)
at Gulp.Orchestrator.start (C:\xampp\htdocs\work\node_modules\orchestrator\index.js:134:8)
at C:\Users\58_user\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:129:20
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Module.runMain (module.js:607:11)
at run (bootstrap_node.js:418:7)
这个问题怎么解决?请帮帮我,有没有人能提供角阀的安装指南,先谢谢了
3条答案
按热度按时间nkoocmlb1#
删除不必要未定义任务
changed
..pipe(changed(img_dest))
。fivyi3re2#
在
var gulp = require ('gulp');
之后添加以下代码行:xu3bshqb3#
其他简单的解决方案,如果您想使用require(),只需更改版本
备注
[不使用.pipe(已更改())]